Skip to main content

Phoneme advanced, personal profile, PNG images

11 replies [Last post]
jldominguez
Offline
Joined: 2008-01-02
Points: 0

Hello, list. I am using PNG images in my application but when I read them with the Toolkit and paste them on a Graphics object, the alpha band is not read properly, so the pixels are either transparent or opaque, but not semi-transparent. is this a known bug/issue? Is there a workaround?

I am using Davy's CAB installer (advanced, personal profile, on Windows Mobile 5)

Thanks,
Lucas

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
jldominguez
Offline
Joined: 2008-01-02
Points: 0

This is more or less what I mean:

https://correo.prodevelop.es/descarga/mobile/png_alpha.jpg

Seems like phoneMe's toolkit is reading just one bit of the alpha band, so if the alpha band is >= 128, it's opaque, and if alpha <= 127, it's transparent (or viceversa)

Cheers
Lucas

jldominguez
Offline
Joined: 2008-01-02
Points: 0

This is more or less what I mean:

https://correo.prodevelop.es/descarga/mobile/png_alpha.jpg

Seems like phoneMe's toolkit is reading just one bit of the alpha band, so if the alpha band is >= 128, it's opaque, and if alpha <= 127, it's transparent (or viceversa)

Cheers
Lucas

Hinkmond Wong

phonemeadvanced@mobileandembedded.org wrote:
> This is more or less what I mean:
>
> https://correo.prodevelop.es/descarga/mobile/png_alpha.jpg
>
> Seems like phoneMe's toolkit is reading just one bit of the alpha band, so if the alpha band is >= 128, it's opaque, and if alpha <= 127, it's transparent (or viceversa)
>
> Cheers
> Lucas
>

Hi Davy,

Do you happen to know whether Windows Mobile 5.0 (or PocketPC 2003) can
support alpha blending (with a bit depth of 128)?

Thanks,
Hinkmond

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

Davy Preuveneers

On Tuesday 12 August 2008, Hinkmond Wong wrote:
> phonemeadvanced@mobileandembedded.org wrote:
> > This is more or less what I mean:
> >
> > https://correo.prodevelop.es/descarga/mobile/png_alpha.jpg
> >
> > Seems like phoneMe's toolkit is reading just one bit of the alpha band,
> > so if the alpha band is >= 128, it's opaque, and if alpha <= 127, it's
> > transparent (or viceversa)
> >
> > Cheers
> > Lucas
>
> Hi Davy,
>
> Do you happen to know whether Windows Mobile 5.0 (or PocketPC 2003) can
> support alpha blending (with a bit depth of 128)?

I am afraid it doesn't. I just tested the following image with the IE browser
on WM2003, WM5 and WM6, and the transparency of the image is quite different
in my desktop browser.

http://www.w3.org/Graphics/PNG/alphatest.png

Regards,
Davy

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

Hinkmond Wong

Davy Preuveneers wrote:
> On Tuesday 12 August 2008, Hinkmond Wong wrote:
>
> Do you happen to know whether Windows Mobile 5.0 (or PocketPC 2003) can
> support alpha blending (with a bit depth of 128)?
>
>
> I am afraid it doesn't. I just tested the following image with the IE browser
> on WM2003, WM5 and WM6, and the transparency of the image is quite different
> in my desktop browser.
>
> http://www.w3.org/Graphics/PNG/alphatest.png
>

Hi Davy,

Thanks for the confirmation test.

Lucas, sorry but that's not our phoneME causing the issue you are seeing
the 1-bit alpha blending on Windows Mobile. That's a native Windows
Mobile issue.

Hinkmond

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

jldominguez
Offline
Joined: 2008-01-02
Points: 0

Hi. This is in more detail what I mean:

http://gvsigmobileonopenmoko.files.wordpress.com/2008/08/message.pdf

Thanks,
Lucas

Hinkmond Wong

phonemeadvanced@mobileandembedded.org wrote:
> Hi. This is in more detail what I mean:
>
> http://gvsigmobileonopenmoko.files.wordpress.com/2008/08/message.pdf
>
> Thanks,
> Lucas
>

Hi Lucas,

I think you are seeing that the IBM J9 must be doing their alpha
blending in buffered image processing in their runtime library instead
of using the Windows Mobile native functions to do the alpha blending.

Currently, in phoneME there is no Java side image processing to support
alpha blending on Windows Mobile. If you or some other developer on
this forum would like to volunteer to work on that, let us know and we
can help you get started and take back your contribution for the phoneME
project.

It would be a good isolated task to work as to help our open source
project and others needing the same functionality.

Thanks,

Hinkmond

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

Davy Preuveneers

On Thursday 14 August 2008, Hinkmond Wong wrote:
> phonemeadvanced@mobileandembedded.org wrote:
> > Hi. This is in more detail what I mean:
> >
> > http://gvsigmobileonopenmoko.files.wordpress.com/2008/08/message.pdf
> >
> > Thanks,
> > Lucas
>
> Hi Lucas,
>
> I think you are seeing that the IBM J9 must be doing their alpha
> blending in buffered image processing in their runtime library instead
> of using the Windows Mobile native functions to do the alpha blending.
>
> Currently, in phoneME there is no Java side image processing to support
> alpha blending on Windows Mobile. If you or some other developer on
> this forum would like to volunteer to work on that, let us know and we
> can help you get started and take back your contribution for the phoneME
> project.
>
> It would be a good isolated task to work as to help our open source
> project and others needing the same functionality.
>
>
> Thanks,
>
> Hinkmond

I was just about to reply the same. My previous alpha blending tests were done
with IE on the Windows Mobile emulators and on my PDA, and they showed the
same kind of errors as those in the pdf. On my PDA, I have another viewer
that shows png with alpha channels correctly. So I guess J9 is indeed doing
alpha blending on its own.

Moreover, while a pMEA linux build with Qt produces correct results, a pMEA
GTK build does not. I haven't looked at the Qt AWT peer implementation to see
if there is special code to handle alpha blending, or if Qt handles this all
by itself.

Davy

[signature.asc]

Davy Preuveneers

Just to quickly reply to myself:

While the problem is best solved in the VM itself, you can also do the alpha
blending in your application itself.

http://www.cs.kuleuven.ac.be/~davy/phoneme/test/ImageViewer.java

I first draw a background image "back.png" using a standard image drawing
method, and then I draw a transparent image "alpha.png" pixel by pixel while
blending the alpha channels.

The code is rather slow, and just serves as a proof of concept. If you want to
optimize, eliminate the creation of the Color objects and compute the
blending directly with the integers. You can also replace the setRGB call

offscreenSurface.setRGB(x + startX, y + startY, newColor.getRGB());

with

blendPixels[y*width + x] = newColor.getRGB();

and then after blending the pixels, you can create an Image object that you
draw like the first image:

image = createImage(new MemoryImageSource(width, height, blendPixels, 0,
width));
Graphics2D g2d = (Graphics2D)offscreenSurface.getGraphics();
g2d.drawImage(image, 0, 0, null);

Davy

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

jldominguez
Offline
Joined: 2008-01-02
Points: 0

Hello. The pixel-by-pixel approach is a bit scary in this young JME world :-P

Anyway, I'll try your code. Thanks for the reply.

Davy Preuveneers

On Friday 15 August 2008, phonemeadvanced@mobileandembedded.org wrote:
> Hello. The pixel-by-pixel approach is a bit scary in this young JME world
> :-P
>
> Anyway, I'll try your code. Thanks for the reply.
> [Message sent by forum member 'jldominguez' (jldominguez)]

I am well aware that this method can be a few hundred times slower :-)

Windows Mobile 5 provides the AlphaBlend method call, but it appears that not
all devices support it. I have read some reports on forums that the Imaging
API is rather slow too:

http://msdn.microsoft.com/en-us/library/ms879887.aspx
http://msdn.microsoft.com/en-us/library/aa452202.aspx

But it is probably faster than the Java implementation. If the AlphaBlend
method does not work, I can only hope that providing a native blending
implementation helps.

Davy

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