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. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Cascades Development

Reply
Regular Contributor
nemory
Posts: 78
Registered: ‎05-21-2012
My Carrier: WiFi

HELP - problems with SCALE and POSITION when saving an image on top of another image

HELP - problems with SCALE and POSITION when saving an image on top of another image

 

//this has rotation, and scale pinch event handlers and working well
object = ImageView::create("asset:///images/itsmorefunlogo.png"); QImageReader reader; reader.setFileName(appFolder + "app/native/assets/images/background.jpg"); QImage image = reader.read(); QPainter painter(&image); QString bomberFileName = appFolder + "app/native/assets/images/itsmorefunlogo.png"; reader.setFileName(bomberFileName); QImage bombimage = reader.read(); QTransform imageTransform; imageTransform.rotate(object->rotationZ()); imageTransform.scale(object->scaleX(), object->scaleY()); bombimage = bombimage.transformed(imageTransform); painter.drawImage(QPoint(object->translationX(), object->translationY()), bombimage); image.save(fileName, "JPG");

 I am not getting the correct POSITION and SCALE, only the ROTATION is perfect.

In my app I can pinch to scale and rotate the object (ImageView) and I have a button to save it and after it saves, the scale is not the same and the position.

Please use plain text.
Developer
dans
Posts: 20
Registered: ‎11-17-2010
My Carrier: -

Re: HELP - problems with SCALE and POSITION when saving an image on top of another image

Posting some images may help to illustrate what the actual issue is.

 

A shot in the dark: Have you tried reversing the rotate and scale commands (so doing scale first)? The concept of transformation matrices can be tricky if on is not used to them.

 

Daniel

Please use plain text.
Regular Contributor
nemory
Posts: 78
Registered: ‎05-21-2012
My Carrier: WiFi

Re: HELP - problems with SCALE and POSITION when saving an image on top of another image

Initial

 

1.jpg

 

Output

 

2.jpg

Please use plain text.
Regular Contributor
nemory
Posts: 78
Registered: ‎05-21-2012
My Carrier: WiFi

Re: HELP - problems with SCALE and POSITION when saving an image on top of another image

Thank you so much DANS

 

Full source code here: http://tny.cz/ecb114ea

Please use plain text.
Developer
dans
Posts: 20
Registered: ‎11-17-2010
My Carrier: -

Re: HELP - problems with SCALE and POSITION when saving an image on top of another image

Glad I could help.

(why not like the post if it solved the issue:-)

Please use plain text.
Regular Contributor
nemory
Posts: 78
Registered: ‎05-21-2012
My Carrier: WiFi

Re: HELP - problems with SCALE and POSITION when saving an image on top of another image

my issue is not yet solved. :smileyhappy:

Please use plain text.
Regular Contributor
nemory
Posts: 78
Registered: ‎05-21-2012
My Carrier: WiFi

Re: HELP - problems with SCALE and POSITION when saving an image on top of another image

reversing the scale and rotation still does not help :smileysad:

Please use plain text.
Developer
dans
Posts: 20
Registered: ‎11-17-2010
My Carrier: -

Re: HELP - problems with SCALE and POSITION when saving an image on top of another image

I can't see the images yet, just placeholders.

Please use plain text.
Regular Contributor
nemory
Posts: 78
Registered: ‎05-21-2012
My Carrier: WiFi

Re: HELP - problems with SCALE and POSITION when saving an image on top of another image

Sorry, what do you mean?

Please use plain text.