2013年7月23日星期二

Android captureScreen screencast

Hello everyone, I read this http://blog.csdn.net/zmyde2010/article/details/6925498 Bowen, the system also implements want android4.0.3 source with android screenshot. I downloaded the android source code, compile, and compiled separately jni module. Compiled successfully, but the run-time error, Fatal signal 11 (SIGSEGV) at 0x00000000 (code = 1). Through endless investigation and found that this problem may be a function of the library file would pass a null pointer cause. Along the way research, see log found in the cpp file after calling composer-> captureScreen found after the function return value is NO_ERROR, but the heap is null, w, and h is 0, so to call back heap-> ; getBase () error, would like to ask is what causes a problem called? How can I solve. Thank you! ! ~ ~ ~ ~ ~ ~
------ Solution ---------------------------------- ----------
4.03 interface, the interface is not the original
const char * file_path = env-> GetStringUTFChars (file, NULL);

const String16 name ("SurfaceFlinger");
sp composer;
getService (name, & composer);

sp heap;
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?

没有评论:

发表评论