Skip to main content

Image.scaled(int, int)

3 replies [Last post]
kawaiimomo
Offline
Joined: 2008-07-10

Hello all,

I need to scale a fully opaque Image. Is Image.scaled(int, int) checking if the original Image has translucency or it just perform the scaling preserving the translucent pixels if there are some of them?

I'm asking this because if no check if performed, it would be probably faster to scale the Image by myself ignoring alpha channel.

Thanks and regards.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
kawaiimomo
Offline
Joined: 2008-07-10

Regarding the same question,

is Image.scaledSmallerRatio(int, int), and similar methods, all calling innerly to Image.scaled(int, int)??

If yes, Image.scaled(int, int) perform alpha channel check, or it assumes the image is translucent?

Any guess is welcomed ;-)

Shai Almog

Hi,
scaled always takes alpha into consideration but you will probably
slow down the algorithm if you don't...
Unlike the old MIDP 1.0 code which didn't take alpha into
consideration since it used mutable images, we use ARGB arrays which
are much cheaper. However, we don't manipulate the colors (not
interpolation) which isn't practical for realtime on device
scaling... Since we don't interpolate supporting alpha has 0 overhead.

We do however, check whether the image has alpha if the device has 16
bit colors (e.g. Sony Ericsson). This allows us to use a mutable
image rather create the image from RGB on such devices to make sure
that the image takes less RAM. This doesn't pose a big overhead.

Anyway I highly doubt you can make the algorithm faster for the
opaque case simply because there is no interpolation.

Some methods call to scaled() others don't and the internal
relationship with the deprecated scale() method is complex
historically and uninteresting.

Thanks.

> Regarding the same question,
>
> is Image.scaledSmallerRatio(int, int), and similar methods, all
> calling innerly to Image.scaled(int, int)??
>
> If yes, Image.scaled(int, int) perform alpha channel check, or it
> assumes the image is translucent?
>
> Any guess is welcomed ;-)
> [Message sent by forum member 'kawaiimomo' (kawaiimomo)]
>
> http://forums.java.net/jive/thread.jspa?messageID=288365
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
> For additional commands, e-mail: users-help@lwuit.dev.java.net
>

Shai Almog
http://lwuit.blogspot.com/

[att1.html]

kawaiimomo
Offline
Joined: 2008-07-10

Hi Shai,

Thanks for your reply and explanation. I guess you are right when you say I'd make the algorithm slower, I was assuming there was interpolation...

And thanks for saving us of using mutable images; I can't wait to see that algorithm ;-)

Regards