06-27-2011 02:55 PM
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?
Solved! Go to Solution.
06-27-2011 03:36 PM
Are you using the same source Bitmap and only changing dux, duy, dvx and dvy? What is your sequence of steps?
06-27-2011 03:44 PM - edited 06-27-2011 03:48 PM
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).
06-27-2011 04:34 PM
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.
06-28-2011 10:24 AM
06-28-2011 11:26 AM
It seems like you are overwriting the Bitmap you then feed to drawTexturedPath each time in renderPDF(). Is that intentional?
06-28-2011 12:06 PM - edited 06-28-2011 12:10 PM
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.
06-28-2011 04:01 PM
Is that a problem or is it just general efficiency that your wondering about?
06-28-2011 04:07 PM
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.
06-28-2011 04:22 PM
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?