Java-Gaming.org Hi !
Featured games (81)
games approved by the League of Dukes
Games in Showcase (513)
Games in Android Showcase (119)
games submitted by our members
Games in WIP (576)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Fast Free Commercially Useable PNG Decoder?  (Read 4621 times)
0 Members and 1 Guest are viewing this topic.
Offline counterp

Senior Duke


Medals: 11



« Posted 2011-08-19 12:32:18 »

Does it exist? :O

If not, is there any good documentation on PNG decoding (specifically true color alpha, that's all I need).
Offline Cero
« Reply #1 - Posted 2011-08-19 12:49:51 »

Slick uses Matthias Mann's PNGDecoder  http://l33tlabs.org/#downloads

it's quite good, although there could be more documentation

http://wiki.l33tlabs.org/bin/view/TWL/Using+the+TWL+PNGDecoder

Offline counterp

Senior Duke


Medals: 11



« Reply #2 - Posted 2011-08-19 13:37:12 »

now i'm no lawyer but isn't there something in the license disallowing commercial use for that? at least without permission?

and how would you get a BufferedImage from that?
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline kappa
« League of Dukes »

JGO Kernel


Medals: 78
Projects: 15


★★★★★


« Reply #3 - Posted 2011-08-19 13:41:09 »

now i'm no lawyer but isn't there something in the license disallowing commercial use for that? at least without permission?
the PNGDecoder above is BSD License, so you can use it for commercial use.
Offline Cero
« Reply #4 - Posted 2011-08-19 13:57:01 »

and how would you get a BufferedImage from that?

yeah common problem. I'm not an expert at this and have to fiddle around myself to get stuff like that to work.

my first guess would be to use the BufferedImage.setData method
which requires a Raster, so you use a WriteableRaster
it has a lot of methods like setPixel and setPixels

so from the ByteBuffer, PNGDecoder creates you have to make a Rastern, then apply it.
How exactly and if it is fast - not sure.

but when working with java2D I have just use ImageIO.read which does PNGs aswell of course

Offline Cero
« Reply #5 - Posted 2011-08-19 14:02:42 »

http://www.exampledepot.com/egs/java.awt.image/Mandelbrot2.html

or using a DataBuffer ?

Offline counterp

Senior Duke


Medals: 11



« Reply #6 - Posted 2011-08-19 14:05:21 »

Does the ByteBuffer just contain the pixel data as bytes? like

byte 0 = Red
byte 1 = Green
byte 2 = Blue
byte 3 = Alpha

... repeat

(not necessarily in that order?)
Offline Cero
« Reply #7 - Posted 2011-08-21 23:36:13 »

yeah don't ask me, I would guess so
but absolutely no idea, could be entirely different

Offline Riven
« League of Dukes »

JGO Overlord


Medals: 816
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #8 - Posted 2011-08-22 05:34:32 »

Does the ByteBuffer just contain the pixel data as bytes? like

byte 0 = Red
byte 1 = Green
byte 2 = Blue
byte 3 = Alpha

... repeat

(not necessarily in that order?)
Depends on the value returned by BufferedImage.getType(), and/or the value passed into the constructor.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline pjt33
« Reply #9 - Posted 2011-08-22 06:17:54 »

If not, is there any good documentation on PNG decoding (specifically true color alpha, that's all I need).
When I did a mini-project recently which involved hacking around with pngs I found the spec pretty good.

Question: given that you talk about true-colour alpha being all you need, is it fair to assume that you're in full control of the creation of the images you want to later read? If so, is there a particular reason for using png?
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Cero
« Reply #10 - Posted 2011-08-22 11:15:11 »

If so, is there a particular reason for using png?

It's the best image format there is. Sharp, no artifacts like jpg, stilll not as big as bmp obviously, and supports transparency which is obviously the most important, and there are few other formats that do this well.
Even Ps3 XMB uses pngs.

Offline pjt33
« Reply #11 - Posted 2011-08-22 18:15:29 »

But if png decoding is proving a bottleneck for you, perhaps you should consider using a raw bitmap format and sticking it in your jar. The compression may not be quite as good as png, but the reconstruction would be faster.
Offline counterp

Senior Duke


Medals: 11



« Reply #12 - Posted 2011-08-24 17:23:17 »

size is also important, because I'm working with potentially hundreds of images of large sizes :\

the fastest thing right now is loading the PNG with ImageIO (I tried this method and other PNG decoders, but they are just slower? I found a great PNG encoder though, that is faster than ImageIO)
Offline Matthias

Senior Duke


Medals: 3
Projects: 1


TWL - Themable Widget Library


« Reply #13 - Posted 2011-08-24 18:47:33 »

I did not write PNGDecoder to be used with BufferedImage - it is intended to be used with OpenGL and it decodes into formats understood by OpenGL. And for that it is probably the fastest decoder (and it is small).

As for the byte order - just look at the Format enum (eg RGBA, BGRA etc).
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Longarmx (38 views)
2014-10-17 03:59:02

Norakomi (29 views)
2014-10-16 15:22:06

Norakomi (24 views)
2014-10-16 15:20:20

lcass (28 views)
2014-10-15 16:18:58

TehJavaDev (57 views)
2014-10-14 00:39:48

TehJavaDev (56 views)
2014-10-14 00:35:47

TehJavaDev (47 views)
2014-10-14 00:32:37

BurntPizza (64 views)
2014-10-11 23:24:42

BurntPizza (36 views)
2014-10-11 23:10:45

BurntPizza (78 views)
2014-10-11 22:30:10
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!