Skip to main content

[JAVA2D] C++ -> JNI -> BufferedImage -> Screen ?

1 reply [Last post]
Anonymous

I am using C/C++ native libraries for image loading and working on JNI
code that takes those images into Java. These images are either directly
painted to the screen with Graphics.drawImage(Image,x,y,null); or
Graphics.drawImage(Image,x,y,w,h,null); with the bilinear rendering hint
set.

Whats is the best BufferedImage format to create for fast painting to
screen on Windows?

What is the fastest way to transfer images though JNI?

I read that VALUE_COLOR_RENDER_QUALITY hint should enable converting
images from sRGB (Java Default) to the monitors profile on rendering. Is
this true?

Many Thanks

Jasper Potts

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".

Reply viewing options

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

Hello Jasper,

On Thu, May 05, 2005 at 04:43:02PM +0100, Jasper Potts wrote:
> I am using C/C++ native libraries for image loading and working on JNI
> code that takes those images into Java. These images are either directly
> painted to the screen with Graphics.drawImage(Image,x,y,null); or
> Graphics.drawImage(Image,x,y,w,h,null); with the bilinear rendering hint
> set.
>
> Whats is the best BufferedImage format to create for fast painting to
> screen on Windows?

In theory the best image format could be determined by requesting a
color model of the GraphicsConfiguration associated with the screen:
java.awt.GraphicsConfiguration.getColorModel()
Then you can create a BufferedImage with this color model.

Note that this method returns an opaque ColorModel, so the resulting
image will be opaque.
If your images have transparency or translucencly, you'll need to
use getColorModel(Transparency) call.

However, note that you'll need then to have a way to convert the
image you've loaded into the destination BufferedImage format.

To avoid writing many loops for converting from your image format to
many screen pixel formats, you may want to create a TYPE_INT_ARGB
image and only have a loop to convert to this format.

Then you can either copy it directly to the screen (which may be
slow because this format has alpha and will not be hardware
accelerated), or copy it into an intermediate opaque or bitmask
image.

But may I ask if you considered writing an javax.imageio plugin for
reading your image format (assuming there are no plugins already
that do that).

You can get additional plugins from Java Advanced Imaging
(free+opensource):
https://jai-imageio.dev.java.net/
They have fast codecs for BMP, JPEG, JPEG 2000, PNG, PNM, Raw, TIFF,
and WBMP.

> What is the fastest way to transfer images though JNI?
>
> I read that VALUE_COLOR_RENDER_QUALITY hint should enable converting
> images from sRGB (Java Default) to the monitors profile on rendering. Is
> this true?

I'll defer this to other folks on our team.

Thanks,
Dmitri
Java2D Team

> Many Thanks
>
> Jasper Potts
>
> ===========================================================================
> To unsubscribe, send email to listserv@java.sun.com and include in the body
> of the message "signoff JAVA2D-INTEREST". For general help, send email to
> listserv@java.sun.com and include in the body of the message "help".

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".