Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (109)
games submitted by our members
Games in WIP (536)
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  
  bmp loader  (Read 3419 times)
0 Members and 1 Guest are viewing this topic.
Offline aNt

Senior Member




AFK


« Posted 2003-07-18 14:48:30 »

anyone got around to trying to get a bmp file loader working? just abit stuck without one.. now worry mind..
Archimedes
Guest
« Reply #1 - Posted 2003-07-18 15:12:05 »

No. However why stick with MS' BMPs?

With the free Xnview (1) you could batch-convert all your Bmp files to some more handy format, like the nice Png format (2) or Tga.
Png (and Jpeg) is being supported directly by Java (javax.imageio.*). So with two or three lines of code you load Png files (3) and give them as textures to your OpenGL/Jogl project.


(1) http://www.xnview.com  - Xnview handles about 99% of the functions of Acdsee, however supports many more formats and is free.

(2) http://www.w3.org/Graphics/PNG/

(3) This is one of the many reasons why I love Java so much: its large and usable standard library lets you really concentrate on your job. :-)
Offline tortoise

Junior Member




<3 Shmups


« Reply #2 - Posted 2003-07-18 15:27:39 »

But what is the deal with alpha transparency and pngs!? If I understand correctly pngs don't define a specific alpha channel, but encode their transparency by other means.

Confusion was greatly added when Adobe attempted to jump the gun on pngs and implemented png transparencies in Photoshop 5 with an alpha channel, causing lots of confusing info to ripple out all over the net.

When ImageIO loads a png that has transparency, the resulting BufferedImage is not in RGBA format. However drawing it with a Graphics object results in correct transparency.

I finally gave up and went with targas. I like the tangible and easy to work with alpha channel anyway.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline aNt

Senior Member




AFK


« Reply #3 - Posted 2003-07-18 15:46:13 »

because MD2 models use BMP files.... if they didnt i would be happy Smiley but they do so.. oh well..
Archimedes
Guest
« Reply #4 - Posted 2003-07-18 16:16:11 »

Quote
But what is the deal with alpha transparency and pngs!? If I understand correctly pngs don't define a specific alpha channel, but encode their transparency by other means.

Unfortunately I don't know.

Quote
When ImageIO loads a png that has transparency, the resulting BufferedImage is not in RGBA format. However drawing it with a Graphics object results in correct transparency.

I finally gave up and went with targas. I like the tangible and easy to work with alpha channel anyway.

Yes, Targas are a nice format, our artists love it. Still, when they do transparency textures with Lightwave, they insist in having the alpha layer in an own picture file (no matter if it's PNG or TGA).
Archimedes
Guest
« Reply #5 - Posted 2003-07-18 16:18:47 »

Quote
because MD2 models use BMP files.... if they didnt i would be happy :) but they do so.. oh well..

Oh, I see.
And which graphic format does MD3 support?
Offline aNt

Senior Member




AFK


« Reply #6 - Posted 2003-07-18 16:39:41 »

bmp also Smiley i have a md3 loader also. but the textures are still bmp... thats way i asked... i guess i could pre convert all the images to somthing else... just would be a downer... nice md2 and md3 exporters for modelers out there.
Archimedes
Guest
« Reply #7 - Posted 2003-07-18 18:07:16 »

Quote
bmp also :) i have a md3 loader also. but the textures are still bmp... thats way i asked... i guess i could pre convert all the images to somthing else... just would be a downer... nice md2 and md3 exporters for modelers out there.

Interestingly the MD3 models of the nice game Jedi Outcat use TGA files as texture file format. The textures are stored as JPG files in the Pk-Zip-Archiv but when you convert them to TGA you can watch the models with a MD3 viewer.

Some info about various graphics formats are available here: http://www.wotsit.org/

PS: Does anybody know of a better site than the above for various formats?
Offline zparticle

Senior Member




Thick As A Brick


« Reply #8 - Posted 2003-07-18 19:24:57 »

Quote
anyone got around to trying to get a bmp file loader working? just abit stuck without one.. now worry mind..


download
http://www.scottshaver2000.com/files/lwjgl_sg/lwjgl_sg_src.zip

and look and the ImageFile and WindowsBitmapFile classes.

Offline vydias

Senior Newbie




Welcome to my world!


« Reply #9 - Posted 2003-07-20 04:03:56 »

TGA images are nice but lets also remember that many java games for the forseeable future will be dowloaded not purchased on a cd. If you were to create any type of large scaled 3d game these textures alone would probably require over 100mbs. Not acceptable for a downloaded game when you also have to add into that the code, sounds, data files, map/lvl files, model files etc...

With this in mind its important to be able to load jpegs and for textures with an alpha component to be able to use gif.

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline tortoise

Junior Member




<3 Shmups


« Reply #10 - Posted 2003-07-20 04:23:14 »

But since jpegs and gifs are already compressed, you can't squeeze much out of them.

I just threw one of my tga textures into a jar and got 77% compression. Some jpeg I have laying around thrown in only gave me 6% compression. I'd be willing to bet that in the end the difference won't be that large.
Offline swpalmer

JGO Coder




Where's the Kaboom?


« Reply #11 - Posted 2003-07-20 04:32:01 »

Compression depends a lot on image content.  JPEG compression will be VERY good for photo like images.  Since it is lossy there is a lot of tuning you can do and the compression would be much better for that style of image than zipping a TGA.  If you need crisp lines with high frequency detail then zipping a TGA might be better than wrecking the images with a lossy compressor.  PNGs also are compressed pretty good and not lossy.. zipping won't do much more to them.

If you want to go non-lossy I would choose PNG simply because the loader is built-in and it supports any feature you would likely need (Alpha, Gamma, various palette sizes + true colour).

Offline gregorypierce

Senior Member




I come upon thee like the blue screen of death....


« Reply #12 - Posted 2003-07-20 04:36:24 »

My personal advice is to use whatever texture is necessary to make the game work, just be responsible. I use PNGs for most things at this point becase they work well for what I'm trying to do. Between the various image formats I have found little to no difference once the formats have all been compressed between their relative sizes. I've taken the same image - a 512x512 and tried it as JPEG, PNG, and TGA and once it was compressed, there really wasn't much difference in size. Since you can read images right from the .zip format, not really a big deal about compressing textures for production content.

http://www.gregorypierce.com

She builds, she builds oh man
When she links, she links I go crazy
Cause she looks like good code but she's really a hack
I think I'll run upstairs and grab a snack!
Offline aNt

Senior Member




AFK


« Reply #13 - Posted 2003-07-20 12:55:22 »

most of the time i use TIM2 image files. i find when u use a TGA u still need up uncompress it before using it. so its just to big. its cool for Output mind.. just using BMP because i have millions of BMP textures. NP i am recompressing them..

fun fun fun Smiley....
Offline vydias

Senior Newbie




Welcome to my world!


« Reply #14 - Posted 2003-07-20 15:14:54 »

If I need to put my jpeg compression down to about 8 or my gif color table down to 64 or 128 colors, sacrificing quality I get a lot smaller file sizes then zipping TGA or png files. About 1/4 of the file size for jpegs without sacrificing much in quality.

There are instances where it would be useful to load in textures in the format that I origionally saved them in because that already yielded the best quality/size ratio I could get.

Looking forward to your loader with any image type.




Archimedes
Guest
« Reply #15 - Posted 2003-07-22 05:24:45 »

Quote
But what is the deal with alpha transparency and pngs!? If I understand correctly pngs don't define a specific alpha channel, but encode their transparency by other means.

I now learned that PNG does allow to have a 8 bpp Alphamask and it works great. :-)

With the help of Gregor's nice Jogl texture mapping tutorial I've now successfully loaded 32-bpp PNGs which contain 24 bpp RGB plus 8 bpp Alphamask.
Java does do this with just a few lines of code and it works very well.
Of course it also works with 24-bpp PNGs with no Alphamask.

Basically you just do this:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
BufferedImage img = ImageIO.read(new File("filename.png"));
// flip it or not. :)
int rgbFormat = (img.getAlphaRaster() == null) ? GL.GL_RGB : GL.GL_RGBA;
byte[] bytearray = ( (DataBufferByte) img.getRaster().getDataBuffer() ).getData();

final int internalOglFormat = rgbFormat;
gl.gluBuild2DMipmaps(o.GL_TEXTURE_2D,
                       internalOglFormat,
                       img.getWidth(), img.getHeight(),
                       rgbFormat,
                       o.GL_UNSIGNED_BYTE,
                       bytearray);


Thanks to the others for the tutorial steps. Now that's the easyness of Java I love.
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.

CogWheelz (18 views)
2014-07-30 21:08:39

Riven (24 views)
2014-07-29 18:09:19

Riven (15 views)
2014-07-29 18:08:52

Dwinin (12 views)
2014-07-29 10:59:34

E.R. Fleming (33 views)
2014-07-29 03:07:13

E.R. Fleming (12 views)
2014-07-29 03:06:25

pw (43 views)
2014-07-24 01:59:36

Riven (43 views)
2014-07-23 21:16:32

Riven (30 views)
2014-07-23 21:07:15

Riven (31 views)
2014-07-23 20:56:16
List of Learning Resources
by SilverTiger
2014-07-31 18:29:50

List of Learning Resources
by SilverTiger
2014-07-31 18:26:06

List of Learning Resources
by SilverTiger
2014-07-31 13:54:12

HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54
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!