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
rcmaniac25
Posts: 1,804
Registered: ‎04-28-2009
My Device: Z10 (STL100-4)-10.2.1.2174, Z10 (STL100-3)-10.3.0.700 Dev OS, Z30 (STA100-5)-10.3.0.700 Dev OS, PlayBook (16GB)-2.1.0.1917
My Carrier: Verizon
Accepted Solution

Transforming a drawn region with drawTexturedPath

I use drawTexturedPath to draw an image within a field. I use drawTexturedPath because the image can be rotated and scaled.

 

I mantain a matrix and use VecMath to transform the drawing region, this matrix can change based on user interaction.

 

Everything works fine until I need to redraw the image with a different transformation. The image seems to stay in place of the previous transformation and is simply "clipped" based on the new transformations.

 

Is there a way to transform the image and have it actually change instead of simply getting clipped?

---Spends time in #blackberrydev on freenode (IRC)----
Three simple rules:
1. Please use the search bar before making new posts.
2. "Like" posts that you find helpful.
3. If a solution has been found for your post, mark it as solved.
--I code too much. Well, too bad.
Please use plain text.
Developer
arkadyz
Posts: 2,268
Registered: ‎07-08-2009
My Device: various
My Carrier: various

Re: Transforming a drawn region with drawTexturedPath

Are you using the same source Bitmap and only changing dux, duy, dvx and dvy? What is your sequence of steps?

----------------------------------------------------------
please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!
Please use plain text.
Developer
rcmaniac25
Posts: 1,804
Registered: ‎04-28-2009
My Device: Z10 (STL100-4)-10.2.1.2174, Z10 (STL100-3)-10.3.0.700 Dev OS, Z30 (STA100-5)-10.3.0.700 Dev OS, PlayBook (16GB)-2.1.0.1917
My Carrier: Verizon

Re: Transforming a drawn region with drawTexturedPath

[ Edited ]

It's usually the same Bitmap (I haven't tested with a new Bitmap). I calculate dux, duy, dvx, and dvy each time I draw.

 

It's an open source project, so here's the source project: http://pdfrend4bb.codeplex.com/

 

Linking directly to the file isn't working. It's located under "Source Code"->Browse (right hand side)->PDFViewer->src. Then the full path is "com.sun.pdfview.FullPageField" (sorry for the inconvenience)

 

Check the paint function. The "drawnPage" Bitmap only gets changed if the scale changes since that is the only time I want to rerender it (takes some time. Want UX to be somewhat good).

---Spends time in #blackberrydev on freenode (IRC)----
Three simple rules:
1. Please use the search bar before making new posts.
2. "Like" posts that you find helpful.
3. If a solution has been found for your post, mark it as solved.
--I code too much. Well, too bad.
Please use plain text.
Developer
rcmaniac25
Posts: 1,804
Registered: ‎04-28-2009
My Device: Z10 (STL100-4)-10.2.1.2174, Z10 (STL100-3)-10.3.0.700 Dev OS, Z30 (STA100-5)-10.3.0.700 Dev OS, PlayBook (16GB)-2.1.0.1917
My Carrier: Verizon

Re: Transforming a drawn region with drawTexturedPath

Ok, just tried it out when the image changes. The image is still drawn directly in the field rather than where the transformed region I want it to draw in is located.

 

It's like the first time I draw is cements the position the image will be drawn while the region around it can change.

---Spends time in #blackberrydev on freenode (IRC)----
Three simple rules:
1. Please use the search bar before making new posts.
2. "Like" posts that you find helpful.
3. If a solution has been found for your post, mark it as solved.
--I code too much. Well, too bad.
Please use plain text.
Developer
rcmaniac25
Posts: 1,804
Registered: ‎04-28-2009
My Device: Z10 (STL100-4)-10.2.1.2174, Z10 (STL100-3)-10.3.0.700 Dev OS, Z30 (STA100-5)-10.3.0.700 Dev OS, PlayBook (16GB)-2.1.0.1917
My Carrier: Verizon

Re: Transforming a drawn region with drawTexturedPath

Is there anything else you need to know?
---Spends time in #blackberrydev on freenode (IRC)----
Three simple rules:
1. Please use the search bar before making new posts.
2. "Like" posts that you find helpful.
3. If a solution has been found for your post, mark it as solved.
--I code too much. Well, too bad.
Please use plain text.
Developer
arkadyz
Posts: 2,268
Registered: ‎07-08-2009
My Device: various
My Carrier: various

Re: Transforming a drawn region with drawTexturedPath

It seems like you are overwriting the Bitmap you then feed to drawTexturedPath each time in renderPDF(). Is that intentional?

----------------------------------------------------------
please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!
Please use plain text.
Developer
rcmaniac25
Posts: 1,804
Registered: ‎04-28-2009
My Device: Z10 (STL100-4)-10.2.1.2174, Z10 (STL100-3)-10.3.0.700 Dev OS, Z30 (STA100-5)-10.3.0.700 Dev OS, PlayBook (16GB)-2.1.0.1917
My Carrier: Verizon

Re: Transforming a drawn region with drawTexturedPath

[ Edited ]

Yes, renderPDF should only be called if the scale is changed or PDF is changed. It doesn't get called every single time. Even then I have a small update (I'll push it out right after this post) that uses the built in "getImage" function in a PDFPage which cache's the image to reduce redraws as long as the image is the same size.

 

Edit: Minor update pushed.

---Spends time in #blackberrydev on freenode (IRC)----
Three simple rules:
1. Please use the search bar before making new posts.
2. "Like" posts that you find helpful.
3. If a solution has been found for your post, mark it as solved.
--I code too much. Well, too bad.
Please use plain text.
Developer
rcmaniac25
Posts: 1,804
Registered: ‎04-28-2009
My Device: Z10 (STL100-4)-10.2.1.2174, Z10 (STL100-3)-10.3.0.700 Dev OS, Z30 (STA100-5)-10.3.0.700 Dev OS, PlayBook (16GB)-2.1.0.1917
My Carrier: Verizon

Re: Transforming a drawn region with drawTexturedPath

Is that a problem or is it just general efficiency that your wondering about?

---Spends time in #blackberrydev on freenode (IRC)----
Three simple rules:
1. Please use the search bar before making new posts.
2. "Like" posts that you find helpful.
3. If a solution has been found for your post, mark it as solved.
--I code too much. Well, too bad.
Please use plain text.
Developer
arkadyz
Posts: 2,268
Registered: ‎07-08-2009
My Device: various
My Carrier: various

Re: Transforming a drawn region with drawTexturedPath

I'm just thinking that by drawing into the Bitmap (or replacing it) you get it clipped along the current borders. If you then use it again, you'll see that clipping in the new image. That's why I think it's beneficial to always retain some kind of primary reference and use it read-only.

----------------------------------------------------------
please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!
Please use plain text.
Developer
rcmaniac25
Posts: 1,804
Registered: ‎04-28-2009
My Device: Z10 (STL100-4)-10.2.1.2174, Z10 (STL100-3)-10.3.0.700 Dev OS, Z30 (STA100-5)-10.3.0.700 Dev OS, PlayBook (16GB)-2.1.0.1917
My Carrier: Verizon

Re: Transforming a drawn region with drawTexturedPath

Hmm, I understand what your saying but I don't think that is the issue. The final goal is for the image to move with "page". The clipping I mentioned is that if I move the "page", the image stays in the same location and seems to be clipped. If clipping regions were maintained by the image then I shouldn't be able to redraw the image in different locations, because it would be clipped outside of that region.

 

Would images describing what the problem is and what the goal is help?

---Spends time in #blackberrydev on freenode (IRC)----
Three simple rules:
1. Please use the search bar before making new posts.
2. "Like" posts that you find helpful.
3. If a solution has been found for your post, mark it as solved.
--I code too much. Well, too bad.
Please use plain text.