Hi, thanks for ur sample code. As i said, they are some application screens made up of graphics component. For eg. Gallery3D application, all the component there in screen are graphics component. (those component can't see through hierarchy viewer tools) Can't test it through robotium. Only way to test the applicaiton is clickOnScreen() with x,y co-ordinate and for every action need to capture the screen and finally verify it with the captured image.
below code will capture only android component(i.e widget component) On Fri, Jun 3, 2011 at 6:00 PM, New Developer <[email protected]> wrote: > Well after much trial and error I managed to capture the entire layout or > activity > using the following code > > View myView = findViewById(R.id.form); > Bitmap bmp = Bitmap.createBitmap( myView.getMeasuredWidth() , > myView.getMeasuredHeight() , Config.ARGB_8888); > Canvas canvas = new Canvas(bmp); > myView.draw(canvas); > try { > FileOutputStream out = new FileOutputStream( "/sdcard/screen.jpg" ); > bmp.compress(Bitmap.CompressFormat.JPEG, 100, out); > out.flush(); > out.close(); > } catch (Exception e) { > e.printStackTrace(); > } > > Not sure if this will help or not ? NOTE: that you can also save as a PNG > if you want . > > > > > > On Jun 3, 2011, at 8:11 AM, Bharathi raja wrote: > > Hi, > Thanks for sharing code. > > Code u shared will capture the entire screen, even if it is not widget > component. > [mean screen may have android or flash or web component] > i wanted to capture all the three. > > Regards, > Bharathiraja R > > On Fri, Jun 3, 2011 at 1:39 AM, New Developer <[email protected]> wrote: > >> Okay I output my bitmap to file as PNG and it only shows the visible >> portion of the layout >> What is currently seen on the screen not the entire layout. >> So would I change the onClick Code to capture the entire layout ? >> >> thanks in advance >> >> >> On Jun 2, 3:35 pm, New Developer <[email protected]> wrote: >> > I'm trying to do something similar >> > >> > Inside my button's OnClick I have >> > >> > View myView = arg0.getRootView(); >> > myView.setDrawingCacheEnabled( true ); >> > mPDF.addImage( myView.getDrawingCache() ); >> > >> > I'm hoping this will capture the screen to a bitmap >> > >> > my PDF.addImage is as follows: >> > >> > public void addImage(Bitmap bmp) { >> > ByteArrayOutputStream bos = new ByteArrayOutputStream(); >> > bmp.compress(CompressFormat.JPEG, 100 , bos); >> > >> > mImage += "5 0 obj \n" + >> > "<< /Type /XObject\n" + >> > " /Subtype /Image\n" + >> > " /Width " + bmp.getWidth() + " \n" >> + >> > " /Height " + bmp.getHeight() + " \n" >> + >> > " /ColorSpace /DeviceRGB\n" + >> > " /BitsPerComponent 8\n" + >> > " /Length " + bos.size() + "\n" + >> > " /Filter /ASCIIHexDecode\n" + >> > ">>\n\n" + >> > "stream\n"; >> > >> > mImage += bos.toString() + "\n"; >> > >> > mImage += "endstream\n" + >> > "endobj\n\n"; >> > } >> > >> > 1) Is the onClick the correct way to capture the screen to bitmap ? >> > 2) Is the PDF code the correct way to store an image inside a PDF ? >> > >> > thanks in advance >> > >> > On Jun 2, 3:11 pm, Paul Turchenko <[email protected]> wrote: >> > >> > >> > >> > >> > >> > >> > >> > > Your process will need permission to do that. ADB has it by default, >> > > but regular apps don't. Unless you're rooted, you can't do that. >> > >> > > On Jun 2, 4:27 am, Bharathiraja R <[email protected]> >> > > wrote: >> > >> > > > Hi All, >> > >> > > > Want sample code to capture screenshot of current screen from phone, >> > > > same like ddms (screen capture). >> > > > Please help me out. >> > >> > > > Regards, >> > > > Bharathiraja R >> >> -- >> You received this message because you are subscribed to the Google >> Groups "Android Developers" group. >> To post to this group, send email to [email protected] >> To unsubscribe from this group, send email to >> [email protected] >> For more options, visit this group at >> http://groups.google.com/group/android-developers?hl=en >> > > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en > > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en > -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

