Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

apocalexiz

loading an image

This topic is 5493 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hy there i want to use *.tga files for my textures...so i want to write my own picture loader the *.tga file specs dont look hard to understand but my problem is...whats the best and fast way to store some picture in memory? so that iam able to present the data to opengl and opengl will show it i dont want to see any sourccode about tga files but if anybody knows some easy implementations of a *.bmp loader or something, give it to me bye

Share this post


Link to post
Share on other sites
Advertisement
quote:
so i want to write my own picture loader the *.tga file

quote:
i dont want to see any sourccode about tga files

You really don''t know what you want, do you?
quote:
but if anybody knows some easy implementations of a *.bmp loader or something, give it to me

Look up the NeHe tutorials (http://nehe.gamedev.net/). He''s got a working implementation of a BMP texture loader in his tuts.

Share this post


Link to post
Share on other sites
I''m assuming you''re using OpenGL since Direct3D has the D3DX library to load images for you.

My advice would be to load the image file header into a matching structure (you may have to use #pragma pack to make sure your structure is tightly aligned), allocate a buffer big enough to hold the image data in, read in the image data, pass it to opengl using the a format compatible with that in the image header, then free your buffer.


Why you shouldn''t use iostream.h - ever! | A Good free online C++ book

Share this post


Link to post
Share on other sites
kingston
********

i already have the file format specification

sisapete
********

>pass it to opengl using the a format compatible with that in
>the image header

where can i look up wich formats r compatible with tga? because i also want to use the alpha value...

extracting the image data is no problem, i know where to find and how to determine the length...

bye

Share this post


Link to post
Share on other sites
so it''s easy to pass the data to GL use the BMP format.

windows has the header structs of the BMP frmt already defined
BMPFILEHEADER & BMPINFOHEADER

just read a BMPFILEHEADER and a BMPINFOHEADER from the start of the file, then seek to the fileheader.bioffBits position and read the data. one tricky thing is that bmp has the images rows aligned to 4bytes. that means that if the image is 255X255 each column in fact has 256 bytes the last one beeing discardable.

its extremely easy. the aux lib of GL has a loading func for dibs (auxDIBimageLoaded or smth like that)

the TGA format is quite similar only the headers differ.

/*ilici*/

Share this post


Link to post
Share on other sites
ahh..i understood...i only have to make a header, that iam able to provide opengl with information like height,width,pixel depth, using alpha or not etc., so that open gl is able to switch in the correct display mode. and i dont need a complete file format description right?

bye

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!