Image.rotate() for 90 degrees: incorrect image's size(width,height)

74 views
Skip to first unread message

Pai Peng

unread,
Aug 7, 2013, 10:45:44 AM8/7/13
to codenameone...@googlegroups.com
Hello CN1,

by using Image.rotate() function I get problem by reading the rotated image's size.

Image temp = image.rotate(90);
Log.p("image size: " + temp.getWidth() + "-" + temp.getHeight(), Log.DEBUG);

I have read an image file to Image object, which has size: 1800-1198.

Then I am using  the code above to rotate this Image object, and what I am waiting for the result of image size is 1198-1800.

But I get the log:
[EDT] 0:0:16,41 - image size: 1800-1198

After rotate the Image object, the image size doesn't be updated.

Is it a bug, or what I have done wrong?

Tested on simulator.


Regards,

Pai



Shai Almog

unread,
Aug 7, 2013, 11:47:25 AM8/7/13
to codenameone...@googlegroups.com
No, the method assumes a square image.
Rotating to a square degree is a special case where this makes sense but if we rotated to 45 degrees then what?

Pai Peng

unread,
Aug 8, 2013, 6:35:17 AM8/8/13
to codenameone...@googlegroups.com
It depends on what the Image could be after rotated by 45 degrees.

For example, if the Image needs to full display, no crop, then it's size is increased.


Regards,

Pai

Pai Peng

unread,
Aug 12, 2013, 6:13:33 AM8/12/13
to codenameone...@googlegroups.com
Hello Shai,

actually what my problem is with captured images on Android device. When they are taken in portrait format, but always displayed in landscape. It is really not acceptable for my app. What I have to do here is adding an new Form for the user to rotate the picture to 90 degrees.

With iOS and Android SDK, this kind of rotation to 90, 180, 270 degrees is also available and after rotation, the new image size is adjusted automatically. This is what I expect also from CN1.




Regards,

Pai


On Wednesday, August 7, 2013 5:47:25 PM UTC+2, Shai Almog wrote:

Shai Almog

unread,
Aug 12, 2013, 12:34:15 PM8/12/13
to codenameone...@googlegroups.com
That is a different use case from the rotate feature and not one that is currently supported out of the box. You could theoretically use getRGB() and shift the pixels into a new image structure but this is obviously less optimal. You can file an RFE for a feature like this but right now we are completely swamped with pro/enterprise requests and I'm just not sure we can handle non-critical issues.

Pai Peng

unread,
Aug 13, 2013, 11:13:36 AM8/13/13
to codenameone...@googlegroups.com
Hello Shai,

I Do Thank you very much!

I know you are working hard on the CN1 and it is still growing.


Regards,

Pai
By the way I am also a PRO user, maybe I should create  a feature request via your support line.

Shai Almog

unread,
Aug 13, 2013, 12:43:25 PM8/13/13
to codenameone...@googlegroups.com
I'm sorry its hard to keep track of all the new subscribers and associate everyone. Just write to the support email and followup with me (its in the subscription tab for pro accounts) I'll make sure to promote the issue.

Shai Almog

unread,
Aug 14, 2013, 4:52:29 AM8/14/13
to codenameone...@googlegroups.com
I was just looking at this issue again, did you use:
Display.getInstance().setProperty("normalizeImage", "true");

This is related to this issue: http://code.google.com/p/codenameone/issues/detail?id=801

I didn't turn it on by default because I wasn't sure the fix worked as expected.

Pai Peng

unread,
Aug 14, 2013, 5:12:59 AM8/14/13
to codenameone...@googlegroups.com
Hi Shai,

great work!

Thank you for so quick support!

Regards,

Pai

Shai Almog

unread,
Aug 14, 2013, 1:08:47 PM8/14/13
to codenameone...@googlegroups.com
Thanks!
I enabled it by default, should be on in the next update.
Reply all
Reply to author
Forward
0 new messages