Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length

 
Advanced search

1075919 Posts in 44152 Topics- by 36120 Members - Latest Member: Royalhandstudios

December 29, 2014, 03:15:46 PM
TIGSource ForumsDeveloperTechnical (Moderators: Glaiel-Gamer, ThemsAllTook)Bitmap RLE8 and 4 decompression
Pages: [1]
Print
Author Topic: Bitmap RLE8 and 4 decompression  (Read 2407 times)
mechacrash
Level 1
*


It's almost like I'm actually being productive!


View Profile Email
« on: March 03, 2010, 12:09:06 PM »

Hey, i am working on a bitmap loader and the last thing i need to do now is RLE compression for 8 and 4 bit bitmaps. I looked at this website: http://gpwiki.org/index.php/LoadBMPCpp and it had code for RLE8 compression. However I do not think this is working as i have copied this almost exactly. When I try to display this in OpenGL I use the type GL_RGB I tried using GL_COLOR_INDEX and nothing appeared, but with GL_RGB the image appears but it is distorted in its colors, it is wrapped around the bottom of the texture and the top is black but the image is half decrypted. I was wondering if anyone knows a website with more on RLE encryption and maybe something decrypting images in C++/OpenGL.

Thanks
Logged

BorisTheBrave
Level 10
*****


View Profile WWW
« Reply #1 on: March 03, 2010, 12:54:47 PM »

Odd graphical glitches usually come from miscalculating the stride of your bitmap, which is not always width * size of one pixel.

But really, why are you doing this, when you could just use pngs? I am sure they compress better than RLE (consider that you can store each pixel as a delta from the previous), and you'd already have premade libraries.
Logged
mechacrash
Level 1
*


It's almost like I'm actually being productive!


View Profile Email
« Reply #2 on: March 03, 2010, 12:57:50 PM »

I'm making a loader for lots of different file types. I don't understand why that example isn't working for me.
Logged

Mikademus
Level 10
*****


The Magical Owl


View Profile
« Reply #3 on: March 03, 2010, 01:13:19 PM »

i have copied this almost exactly
I'd start there.
Logged

\\\"There\\\'s a tendency among the press to attribute the creation of a game to a single person,\\\" says Warren Spector, creator of Thief and Deus Ex. --IGN<br />My compilation of game engines for indies
mechacrash
Level 1
*


It's almost like I'm actually being productive!


View Profile Email
« Reply #4 on: March 03, 2010, 01:42:41 PM »

Well all I have done is change the variable names.
Logged

David Pittman
Level 2
**


MAEK GAEM


View Profile WWW Email
« Reply #5 on: March 03, 2010, 02:53:10 PM »

For starters, don't trust this code. It looks sketchy to me. Put some breakpoints in BMPImg::LoadBmpRLE8() and make sure it isn't hitting any weird cases.

This looks especially suspect:
Code:
case 2:  // Reposition, Never used
  break;
I'd double-check that that case isn't needed in your BMPs--reading about the file format (e.g., here) doesn't suggest that it is actually never used; it may simply be a case the author chose not to handle because his image tools did not export BMPs with that indicator.

Also:
Code:
if(iIndex>iDataSize) // Stop if image size exceeded.
  iDcode=0;
That seems like it should be reporting a warning or assertion failed if not an explicit hard failure case; if image size is exceeded, the program clearly failed in either calculating the image size or reading the data.

Honestly, if you're trying to write your own image loader, you should start by reading the file format spec, and then actually write your own code instead of copying something else. Or if that sounds like a lot of reinventing the wheel, don't write your own image loader. Find a library that does what you need and has been proven in other people's games, and use that instead.
Logged

mechacrash
Level 1
*


It's almost like I'm actually being productive!


View Profile Email
« Reply #6 on: March 04, 2010, 12:00:28 AM »

I looked around on google and i found out about GL_IMAGE_INDEX, i think the RLE8 loader on this website loads the image into and image index format as opposed to RGB so i'm looking for a way to convert from image index to rgb using GL_PIXEL_MAP_I_TO_R G and B. But when I have a chance I will make a new bitmap with RLE8 compression and test it using the spec to see if this function works
Logged

Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic