------ Solution ---------------------------------- ----------
4.03 interface, the interface is not the original
const char * file_path = env-> GetStringUTFChars (file, NULL);
const String16 name ("SurfaceFlinger");
sp
getService (name, & composer);
sp
uint32_t w, h;
PixelFormat f;
status_t err = composer-> captureScreen (0, & heap, & w, & h , & f, 0, 0,0, INT_MAX);
if (err! = NO_ERROR) {
LOGE ("screen capture failed:% s \ n", strerror (-err));
exit (0);
}
LOGD ("screen capture success: w =% u, h =% u, pixels =% p \ n",
w, h, heap-> getBase ());
LOGD ("saving file as PNG in% s ... \ n", file_path);
SkBitmap b;
b.setConfig (SkBitmap :: kARGB_8888_Config, w, h);
b.setPixels (heap-> getBase ());
SkImageEncoder :: EncodeFile (file_path, b,
SkImageEncoder :: kPNG_Type, SkImageEncoder :: kDefaultQuality);
- ---- For reference only ---------------------------------------
Oh Thank you, before I knew the problem, not because of this reason. Finally, I found or competence. No tips insufficient permissions, but to execute the function returns null. . .
------ For reference only -------------------------------------- -
good landlord, I compiled through, but loaded. so it happened Ljava / lang / UnsatisfiedLinkError,
But I put the code in the screenshot function can be replaced by another normal load. SO and properly executed. Landlord does not know touch did not come across this problem?
------ For reference only -------------------------------------- -
landlord Hello, after a pass to get, I told you encounter exactly the same problem, "there is no prompt insufficient permissions, but to execute the function returns null...". This is how you solve, ask
------ For reference only ------------------------------ ---------
written so you do not take it first document, the first written in the executable file, the phone after root java code using Runtime.getRuntime.exec ("su")
performing procedures to obtain the output stream file, see if you can successfully run captureScreen () function.
At present, through lib invoke captureScreen functions are used to solve the signature platform apk have permission to read the framebuffer, but this method is not portable, only in your mobile phone purposes.
I am also studying the specific method, you can slowly exchange
------ For reference only ---------------------- -----------------
that so file problem, there might be function or parameters of some problem, but you have already solved Congratulations ah ha ha
- ----- For reference only ---------------------------------------
My status_t err = composer-> captureScreen (0, & heap, & w, & h, & f, 0, 0 ); This did not go in, but behind printf ("screen capture success: w =% u, h =% u, pixels =% p \ n", this log to break out The value is there but does not generate images on the card t ask why?
没有评论:
发表评论