Skip to main content

createCompatibleImage with transparency

4 replies [Last post]
brunogh
Offline
Joined: 2006-04-23
Points: 0

Hello,

I have noted that createCompatibleImage with transparency mode argument is not exposed in the API, actually is commented at java.awt.GraphicsConfiguration and therefore not implemented in QT subclasses.

Any workarounds to create a transparency image from a width and height?

Thanks,

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Hinkmond Wong

phonemeadvanced@mobileandembedded.org wrote:
> Hello,
>
> I have noted that createCompatibleImage with transparency mode argument is not exposed in the API, actually is commented at java.awt.GraphicsConfiguration and therefore not implemented in QT subclasses.
>
> Any workarounds to create a transparency image from a width and height?
>

Hi brunogh,

I'm not sure I understand your question. If you want to create an image
with transparency, you can use a 3rd party tool such as Gimp or
Photoshop to create a GIF or PNG image file that has transparency set
for the background and then that GIF or PNG file is then used for
loading in Java and drawn to your Graphics.

Is that all you want to do? Draw an image with transparency into your
Graphics of your Java app? If so, then you can do that already with the
current APIs in Java ME CDC PBP and PP.

Thanks,
Hinkmond

---------------------------------------------------------------------
To unsubscribe, e-mail: advanced-unsubscribe@phoneme.dev.java.net
For additional commands, e-mail: advanced-help@phoneme.dev.java.net

brunogh
Offline
Joined: 2006-04-23
Points: 0

Hello Hinkmond,

Thanks for the reply. I think I have not explained correctly ;)

In java.awt.GraphicsConfiguration class, the method createCompatibleImage(widht, height, transparency) that returns a BufferedImage is nos implemented. Is that right?

It seems that the transparency arg can any of the three modes:
bimage = gc.createCompatibleImage(width, height, Transparency.OPAQUE);
bimage = gc.createCompatibleImage(width, height, Transparency.BITMASK);
bimage = gc.createCompatibleImage(width, height, Transparency.TRANSLUCENT);

Thanks in advance.
Bruno

Hinkmond Wong

phonemeadvanced@mobileandembedded.org wrote:
> Hello Hinkmond,
>
> Thanks for the reply. I think I have not explained correctly ;)
>
> In java.awt.GraphicsConfiguration class, the method createCompatibleImage(widht, height, transparency) that returns a BufferedImage is not implemented. Is that right?
>
> It seems that the transparency arg can any of the three modes:
> bimage = gc.createCompatibleImage(width, height, Transparency.OPAQUE);
> bimage = gc.createCompatibleImage(width, height, Transparency.BITMASK);
> bimage = gc.createCompatibleImage(width, height, Transparency.TRANSLUCENT);
>

Hi Bruno,

How are you doing? Sorry, I didn't recognize your userid at first!
Hope you're doing well.

Yes, that's correct. We did not implement createCompatibleImage(with,
height, transparency) in Java ME Personal Profile
java.awt.GraphicsConfiguration. We only implemented
createCompatibleImage(with, height) without transparency to conform to
the spec. which is the way the Personal Profile expert group decided
that they did not want to allow transparencies to be enabled for
Graphics images.

Please see Java ME Personal Profile:
http://java.sun.com/javame/reference/apis/jsr216/java/awt/GraphicsConfig...

Compared against Java SE AWT:
http://java.sun.com/j2se/1.4.2/docs/api/java/awt/GraphicsConfiguration.h...

I believe the EG thought allowing image transparencies would put too
much stress on a limited device that can run Java ME Personal Profile
(which usually has a smaller CPU than PCs or laptops).

So, unfortunately, the best thing to do is to pre-render your images
using a graphics tool (such as Gimp or Photoshop) in GIF or PNG format,
then load those pre-rendered images to use in your Java ME app.

Hope this helps,

Hinkmond

(Uh, sorry to hear about that whole World Cup thingy today. U.S. got
knock out too ;-) )

---------------------------------------------------------------------
To unsubscribe, e-mail: advanced-unsubscribe@phoneme.dev.java.net
For additional commands, e-mail: advanced-help@phoneme.dev.java.net

brunogh
Offline
Joined: 2006-04-23
Points: 0

Thank you Hinkmond! I will take a look.

ps: forget about the world cup, let's get back to work hehe ;)

Cheers,
Bruno