• ### Announcements

#### Archived

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

## Recommended Posts

Yes, how do you do this? I dont like NeHes BMP loading routine. It makes me dizzy. I think resources are the best way of putting BMPs into your program and any help would be greatly appricheated.

##### Share on other sites
I do not know if that is a joke but why should putting the images in a resource file be a good alternative? Only BMPs without alpha channels, pack options, probably more complicated code, ... and does not Windows put some kind of limitations on resource files?

##### Share on other sites
NeHe also has a TGA loader. And if you don''t like that either, use a free image loader library. Myself, I use the Intel JPEG Library and my own TGA loader, but there are some very nice libraries out there that can load any kind of image format.

##### Share on other sites
i''d like to know how to do this also, just so i know.

##### Share on other sites
Moogle: You can use LoadImage() for BMPs, both for files and resources. To access resource data in some other file format, check out FindResource(), LoadResource(), LockResource() and FreeResource(). PaintLib (www.paintlib.de) is a free image library that supports loding images from resources.

Obelix: Why would it be a joke? Reading data from a resource isn''t much more complicated than reading data from a file. Where did you get the idea that only BMPs can be put in a resource?

##### Share on other sites
Try glpng. It''s very easy to use.
In my opinion png is the best format.It is compressed and can store alpha-values.

##### Share on other sites
quote:
I do not know if that is a joke but why should putting the images in a resource file be a good alternative? Only BMPs without alpha channels, pack options, probably more complicated code, ... and does not Windows put some kind of limitations on resource files?

A splash screen image.

Beer - the love catalyst
good ol'' homepage

##### Share on other sites
I do not want to be unfriendly but I can not take the Windows resoure file alternative seriously. If you have a bitmap file can you load it and get the the raw data, width, height and type in one function call.
Doing the same thing with resource files would involve extra steps. Where did the Anonymous Poster get the idea that creating the resource file and calling FindResource(), LoadResource(), LockResource(), FreeResource() and using an extra library for loading images from resources is not much more complicated?
I may of course be wrong about, among other things, the support for bitmaps with alpha channels. I guess that you can have any binary data but how easy is it to use? (creating/loading)

I also think that many libraries helps you in the job of uploading it to the card.

For some reason does Dredge-Master quote me and responds "A splash screen image."

##### Share on other sites
Obelix: sorry if I sounded a bit grumpy yesterday, I had a really bad hangover.
As for resource bitmaps not being a serious alternative, well it is. Trust me.

Oh yeah, login name... maybe I''ll get one of those...

##### Share on other sites
Here is how I do it- Takes a string name to an image and loads it from the resource. You''ll need to heavily modify this code, since I pulled it right from my engine.

  int rcrTexture::LoadRES(LPSTR n){ HBITMAP hBmp; hBmp = (HBITMAP)LoadImage(_rc_GlobalInterface.lpEngineSettings->hInstance,n,IMAGE_BITMAP,0,0,LR_CREATEDIBSECTION); if (hBmp == NULL) { rcEmit("TEXLOAD:: Failed on load of Image %s !\n",n); return 0; } BITMAPINFO BInfo; ZeroMemory(&BInfo,sizeof(BITMAPINFO)); BInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); // okay fix0r the bitmap if (GetDIBits(_rc_GlobalInterface.lpEngineSettings->hDC,hBmp,0,1,NULL,&BInfo,DIB_RGB_COLORS) == 0) { rcEmit("TEXLOAD:: Failed on info call #1 [ GetDIBits() ] of Image %s !\n",n); return 0; } if (CreateBitImage(&BInfo,hBmp) == 0) return 0; DeleteObject(hBmp); return 1; }

The image this returns is NOT MAPPED to the screens bitdepth, cause that would suck if it was low- heh. So I wrote my own function to map all bitmaps into 32bit RGBAs, CreateBitImage().

  int rcrTexture::CreateBitImage(BITMAPINFO *p,HBITMAP hBmp){ BITMAPINFO *bmi; bmi = (BITMAPINFO*)new char[256*4 + sizeof(BITMAPINFOHEADER)]; memcpy (bmi,p,sizeof(BITMAPINFOHEADER)); // ok allocate the bitmap rcBitmap.dwHeight = abs(p->bmiHeader.biHeight); rcBitmap.dwWidth = abs(p->bmiHeader.biWidth); rcBitmap.dwFormat = RCFORMAT_RGBA; rcBitmap.lpBitmap = new unsigned char[rcBitmap.dwWidth * rcBitmap.dwHeight * 4]; BYTE *pIn; pIn = new BYTE[rcBitmap.dwWidth * rcBitmap.dwHeight * 4]; if (GetDIBits(_rc_GlobalInterface.lpEngineSettings->hDC,hBmp,0,rcBitmap.dwHeight,pIn,bmi,DIB_RGB_COLORS) == 0) { rcEmit("TEXLOAD:: Failed on translation #2 [ GetDIBits() ] of Image!\n"); return 0; } // ok loaded the image and pulled the bits- now we need to color adjust if (bmi->bmiHeader.biBitCount <= 8) { // It''s palleted, so do the conversion int NumColors; if (bmi->bmiHeader.biBitCount == 1) NumColors = 2; if (bmi->bmiHeader.biBitCount == 4) NumColors = 16; if (bmi->bmiHeader.biBitCount == 8) NumColors = 256; BYTE *pelOut = rcBitmap.lpBitmap, *pelIn = pIn; DWORD dwPixelCount = rcBitmap.dwWidth * rcBitmap.dwHeight; switch (NumColors) { case 2: break; while (dwPixelCount) { // ok eight pels per byte- so lets do it BYTE pos, x; pos = 1; while ((pos <= 8) && (dwPixelCount)) { x = *pelIn & (1 << pos); pelOut[0] = bmi->bmiColors[x].rgbRed; pelOut[1] = bmi->bmiColors[x].rgbGreen; pelOut[2] = bmi->bmiColors[x].rgbBlue; pelOut[3] = 255; pelOut += 1; dwPixelCount--; pos++; } pelIn += 1; } break; case 16: while (dwPixelCount) { // ok two pels per byte- so lets do it BYTE x; x = *pelIn & 0xF; pelOut[0] = bmi->bmiColors[x].rgbRed; pelOut[1] = bmi->bmiColors[x].rgbGreen; pelOut[2] = bmi->bmiColors[x].rgbBlue; pelOut[3] = 255; pelOut += 4; dwPixelCount--; if (dwPixelCount) { x = (*pelIn & 0xF0) >> 4; pelOut[0] = bmi->bmiColors[x].rgbRed; pelOut[1] = bmi->bmiColors[x].rgbGreen; pelOut[2] = bmi->bmiColors[x].rgbBlue; pelOut[3] = 255; pelOut += 4; dwPixelCount--; } pelIn += 1; } break; case 256: // ok step through the bytes, filling in the proper color data while (dwPixelCount) { pelOut[0] = bmi->bmiColors[*pelIn].rgbRed; pelOut[1] = bmi->bmiColors[*pelIn].rgbGreen; pelOut[2] = bmi->bmiColors[*pelIn].rgbBlue; pelOut[3] = 255; pelOut += 4; pelIn += 1; dwPixelCount--; } break; } } else if (p->bmiHeader.biBitCount == 24) { // okay we just need to pad the alphas BYTE *pelOut = rcBitmap.lpBitmap, *pelIn = pIn; DWORD dwPixelCount = rcBitmap.dwWidth * rcBitmap.dwHeight; while (dwPixelCount) { pelOut[3] = 255; pelOut[2] = pelIn[0]; pelOut[1] = pelIn[1]; pelOut[0] = pelIn[2]; pelOut += 4; pelIn += 3; dwPixelCount--; } } else if (p->bmiHeader.biBitCount == 32) { // okay we just need to swap the red and blue BYTE *pelOut = rcBitmap.lpBitmap, *pelIn = pIn; DWORD dwPixelCount = rcBitmap.dwWidth * rcBitmap.dwHeight; while (dwPixelCount) { pelOut[0] = pelIn[0]; pelOut[1] = pelIn[1]; pelOut[2] = pelIn[2]; pelOut[3] = 255;//pelIn[3]; pelOut += 4; pelIn += 4; dwPixelCount--; } } delete [] pIn; delete [] bmi; return 1;}

##### Share on other sites
acutally- looks like I forgot to swap the red and blue in the 32bit bitmap conversion case <.<

oops (didn''t notice cause I haven''t used it- hehe)

Ranger

##### Share on other sites
Obelix, I quoted you and pointed out what the perfect reason to place an image into a resource file is. The splash screen.

If you want some more commonly used examples, images for the gui such as buttons and diagrams. They are used in most win32 apps, so before you post about resource files being a bad alternative, think about what they can be used for.

PS - you don''t have to store image resources as windows bitmaps. You can store anything in there (use data) and then load out of them. EG PNG image files or PE headers or anything you want.

Beer - the love catalyst
good ol'' homepage

##### Share on other sites
I think that the anonymous posts was informative. We may disagree about some stuff but I think that original question has been answered. If I knew that people used Windows resource files this way should I have expressed myself more careful.

Dredge-Master, all my posts was about using Windows resource files for loading textures as the subject says. I skip the debate about the best way to load images for a splash screen and the stuff in your PS has been covered in earlier posts.

##### Share on other sites
quote:
Original post by Obelix
Dredge-Master, all my posts was about using Windows resource files for loading textures as the subject says. I skip the debate about the best way to load images for a splash screen and the stuff in your PS has been covered in earlier posts.

Acutally no one mentioned a reason to use it, and all you were doing was critising him for putting an image into a resource file.

Then you start getting shitty with people because you''ve been provem wrong about placing only non-alpha channel bitmaps into resources, and also what a valid use for them is.

Now you may want to "skip the debate about the best way to load images for a splash screen" for the very reason that I proved you wrong, but as the first reply to any topic, you really should watch your trap as you never seem to actually try and help anyone, just critisise them.

Moogle asks a valid question (and a sensible one) you flame him, I flame you. Pretty simple isn''t it?

Beer - the love catalyst
good ol'' homepage

##### Share on other sites
quote:
Original post by Dredge-Master
Acutally no one mentioned a reason to use it, and all you were doing was critising him for putting an image into a resource file.

I think you are the only one that does not understand that he asked about how to load textures from resource files. Read the subject next time. I also have the impression that he meant that it should be easier and because of that made the joke remark.

quote:

Then you start getting shitty with people because you''ve been provem wrong about placing only non-alpha channel bitmaps into resources, and also what a valid use for them is.

I answered the Anonymous Poster the same way as he talked to me. Using alpha channels bitmaps is more complicated as he mentioned and a valid use for them was not even discussed.

quote:

Now you may want to "skip the debate about the best way to load images for a splash screen" for the very reason that I proved you wrong, but as the first reply to any topic, you really should watch your trap as you never seem to actually try and help anyone, just critisise them.

No, I want to skip the debate about splash screens because I know that you are a complete idiot. I have the same opinions as before and the same argument could be applied for loading images to the splash screen. Anyone interested could read the previous posts, I think that they show the difference. How did you prove me wrong?
I have always tried to give correct information. If I saw something that I belived was a missunderstanding did I also tried to give the information that I belived was correct.

quote:

Moogle asks a valid question (and a sensible one) you flame him, I flame you. Pretty simple isn''t it?

You have not bother to answer his question or even to understand what he asked about. I had absolutley no intention to flame him. I felt your stupidity and desire to flame and tried to avoid it.

OK, this will be my last post here.

##### Share on other sites
I had no point to post information that was already posted by an anon. Why repeat information that has already been given?

Beer - the love catalyst
good ol'' homepage

##### Share on other sites
Come on, why do you even bother to lie when everybody can read your previous posts?
I guess I am liar also since I promised to not post anymore but this is just a exorcism exception. I like to clear my system.

Dredge-Master, you have
- flamed me
- spreading a lot of crap
- trying to create conflicts that I tried to avoid
- trying to involve others in your crap
- saying that I have bad intentions and motif, I really does not like this one. This is how a worthless little piece of shit acts.
- following and harassing me you really must have flames

I was answering a question and giving the best advice I could. I also tried to explain why I was recommending one solution. It is easy to step on someones toe and I did that but is it not clear that I did not try to flame anyone?
This can be difficult under the best conditions but having some idiot trying to create a flamewar is simply too much.

May I also ask why he is not banned?

##### Share on other sites

Go sequentially through the posts of yourself and mine, and you will understand it.

Beer - the love catalyst
good ol'' homepage

##### Share on other sites
I gave you the opportunity to elaborate I also pointed out that you missed the subject. What did you want from me? Nobody here has any obligation to discuss anything with you. I certainly gave your stupid and offtopic posts more attention than they deserved.

And if that nonsense you are bragging about would be true? Suppose that I had so little selfrespect and it was depending on this technical stuff and I could not admit that you have superior arguments. You would flame me trying to rub it into my face.
You are disgusting.

##### Share on other sites
I gave you the opportunity to elaborate I also pointed out that you missed the subject. What did you want from me? Nobody here has any obligation to discuss anything with you. I certainly gave your stupid and offtopic posts more attention than they deserved.

And if that nonsense you are bragging about would be true? Suppose that I had so little selfrespect and it was depending on this technical stuff and I could not admit that you have superior arguments. You would flame me trying to rub it into my face.
You are disgusting.

##### Share on other sites
read my first post - it wasn''t off topic

##### Share on other sites
Your first post was "A splash screen image.". What has that to do with loading textures from Windows resource files?

You see crap everywhere but the crap is in yourself.

##### Share on other sites
Who did I quote in that post? It was you, and your smart arse comment about resources being useless. Others have also pointed it out. You screwed up and you haven''t got the balls to admit it.

Beer - the love catalyst
good ol'' homepage