Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
abhi007tyagi
Posts: 225
Registered: ‎09-29-2010
My Device: Limited Edition Z10, Playbook
Accepted Solution

Graphics Issue : Need Help

Hi,

 

I am able to display realtime touch areas on screen as if we are writing something on screen.

 

p1.PNG

I am just sensing the touch events and capture the coordinates and drawing points there

 

 

Now I want to capture it and save it in image file. I used screenshot for that but It captures whole screen

I want to capture small part (grey part below) where I can capture my writing and save in image as shown below.

 

 

 p2.PNG

 

 

I have tried Signature capture code but I am not seening any written part on screen, its blank (black part not visible). 

Instead of getGraphics() I am using graphics object. Tried overriding paint() but still same issue.

 

Signature Capture is bit complicated to understand and it has few bugs as well ( a straight line drops a bit then goes straight ). There points are captured and saved in object and through paint() these objects are called and points and paths are painted on bitmap area. This is not what I want as this is very confusing.  

 

I even try to save captured points in objects and call my draw methods from paint() and pass the points saved in objects. But no success.

 

How can I pass and capture graphics context using objects?

or if there is a method of capturing certain part as screenshot that will also do it for me.

 

Thanks

Abhinav Tyagi 

Blackberry Z10-Limited Edition
Blackberry Playbook (won in free playbook offer)
My Apps : pAinT, HealthMeter, Shoot
Developer
abhi007tyagi
Posts: 225
Registered: ‎09-29-2010
My Device: Limited Edition Z10, Playbook

Re: Graphics Issue : Need Help

Please Reply !!!

 

I want to draw on graphic object in realtime.

 

Abhinav Tyagi

Blackberry Z10-Limited Edition
Blackberry Playbook (won in free playbook offer)
My Apps : pAinT, HealthMeter, Shoot
Developer
VivekAgar
Posts: 79
Registered: ‎09-22-2010
My Device: 9700

Re: Graphics Issue : Need Help

use Display.ScreenShot(bitmap,x,y,width,Height)

Method of Display Class ,where u will need to construct a bitmap before calling this method.pass ur Touch Coordinate and then specified Width and Height of Area u want.

Screenshot will be captured in Bitmap.

 then ucan Save thisbitmap on File or where u Want.

 

 

 

============================================================================================

 feel free to press the kudos button on the left side to thank the user that helped you.
please mark posts as solved if you found a solution. 



Developer
abhi007tyagi
Posts: 225
Registered: ‎09-29-2010
My Device: Limited Edition Z10, Playbook

Re: Graphics Issue : Need Help

Thanks  Vivek,

 

I have already mentioned that I have tried screenshot.

I need to capture anything written on grey part.

but problem is I am unable to write on screen at the moment

 

Abhinav Tyagi

Blackberry Z10-Limited Edition
Blackberry Playbook (won in free playbook offer)
My Apps : pAinT, HealthMeter, Shoot
Developer
superdirt
Posts: 541
Registered: ‎05-17-2009
My Device: Not Specified

Re: Graphics Issue : Need Help

ScreenShot is an overloaded method. As VivekAgar mentioned, Display.ScreenShot(bitmap,x,y,width,Height) takes a screen shot of any size, starting at the point (x,y) with a width and a height that you specify. You would be able to take a screen shot of any size with that method, but you need to know the specific (x,y) boundaries of the gray box.

 

Scott

Developer
abhi007tyagi
Posts: 225
Registered: ‎09-29-2010
My Device: Limited Edition Z10, Playbook

Re: Graphics Issue : Need Help

Thanks man,

 

I manage to draw and capture my grey space using bitmap.

But now another issue is coming!!!

 

The drawing coordinates captured are correct but the drawing is getting shifted by 40:20 in X:Y axis in portrait mode by 100:20 in landscape mode. Also I am unable to click buttons using touch method.

Check below

 

p1.PNG

 

 

What could be the reason and how can I improve it?

 

Thanks

Abhinav Tyagi

Blackberry Z10-Limited Edition
Blackberry Playbook (won in free playbook offer)
My Apps : pAinT, HealthMeter, Shoot
Developer
VivekAgar
Posts: 79
Registered: ‎09-22-2010
My Device: 9700

Re: Graphics Issue : Need Help

 u can use

 

 Ui.getUiEngineInstance().setAcceptableDirections(Display.DIRECTION_PORTRAIT|Display.DIRECTION_EAST);

 in ur App's Constructor to restrict the landscape mode.

 

===================================================================================

 

 feel free to press the kudos button on the left side to thank the user that helped you.
please mark posts as solved if you found a solution. 

Developer
abhi007tyagi
Posts: 225
Registered: ‎09-29-2010
My Device: Limited Edition Z10, Playbook

Re: Graphics Issue : Need Help

Issue is not Portrait or Landscape, but the drawn point is not at the same place where I touch the screen

Please check image file. The circle is where I am touching the screen and line is created at a distance and these distance is different in diif orientation.

 

eg. If I touch at 10:10 point get drawn at 50:30 in portratiat and at 110:30 in landscape

 

Also I am unable to use buttons via touch but can use them by scrolling touchpad

 

Thanks

Abhinav Tyagi

Blackberry Z10-Limited Edition
Blackberry Playbook (won in free playbook offer)
My Apps : pAinT, HealthMeter, Shoot
Developer
arkadyz
Posts: 2,268
Registered: ‎07-08-2009
My Device: various

Re: Graphics Issue : Need Help

Where do you override your TouchEvent (screen? manager? field?)? What do you use to extract the points (getX/getY or getGlobalX/getGlobalY)?

 

These questions are important - the field overriding TouchEvent gets the coordinates returned by getX and getY relative to its upper-left corner. If the field is not at the manager's upper left corner and you override TouchEvent on the Manager's level, you are bound to see the shift of (field.getLeft(), field.getTop())

 

getGlobalX and getGlobalY, on the other hand, work relative to the Screen (not the display - non-full Screen such as PopupScreen will get global X and Y different from the physical point on the display). At least that was my impression when I worked much more closely with it.

----------------------------------------------------------
please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!
Developer
abhi007tyagi
Posts: 225
Registered: ‎09-29-2010
My Device: Limited Edition Z10, Playbook

Re: Graphics Issue : Need Help

arkadyz,

Thanks for directing me to right direction.

 

I was overriding TouchEvent at Screen level and using getGlobalX(),Y.

 

I override it at bitmapField and used getX(), Y . My point comes correctly on screen.

 

But I am also using

getMovePoints( ), and this methods draws "Shifted Points". So now I get single point correctly but array points are shifted. In the image below, First point is OK, but rest points captured by getMovePoints( ) are shifted. See the shift from the touch area. 

 

img.PNG

 

What is the replacement for above method as getX is for getGlobalX? 

 

Also I am still not able to click buttons using touch. Only touchpad works here :smileysad:

 

Thanks

Abhinav Tyagi

 

 

 

Blackberry Z10-Limited Edition
Blackberry Playbook (won in free playbook offer)
My Apps : pAinT, HealthMeter, Shoot