|
|
This thread is locked; no one can reply to it.
|
1
2
|
| load_PE_bmp |
|
jeroen valk
Member #12,087
July 2010
|
Hey i was working on loading .egf files desmond had a topic about this and lenny made a system for it i was testing it and i didnt get any errors but when i start the program it says "PE file doesnt have any resources" but i just used gfx025.egf 102 does maybe anyone knows the solution?
|
|
LennyLen
Member #5,313
December 2004
|
If you can email me the *.egf file to lennylen AT woosh DOT co DOT nz, I'll take a look at it. edit: On second thoughts, it's probably too big to email, so you'll need to host it online somewhere.
|
|
Desmond Taylor
Member #11,943
May 2010
|
This is the GFX file that he's on about. I'm also going to test that file for an error too. http://www.mediafire.com/?y0kfildmdry Edit: I used 1ALLEGRO_BITMAP *bmp = load_PE_bmp("gfx/gfx025.egf", 102);
And it worked perfectly. |
|
jeroen valk
Member #12,087
July 2010
|
well i dont know what im doing wrong at the moment i use allegro 4.4.0.2 and i just use exactly the same code as you released ow wait i puted the .c file and the .h again into my source and now i get those errors:'(: Compiler: Default compiler load_PE_bmp.c: In function `BITMAP* load_PE_bmp(const char*, int)': load_PE_bmp.c:122: error: invalid conversion from `void*' to `IMAGE_RESOURCE_DIRECTORY_ENTRY*' load_PE_bmp.c:130: error: invalid conversion from `void*' to `IMAGE_RESOURCE_DIRECTORY*' make.exe: *** [load_PE_bmp.o] Error 1 Execution terminated its about this line: |
|
LennyLen
Member #5,313
December 2004
|
Those errors are because you're compiling C code as C++, which is a lot stricter on casting. You can either fix it yourself by changing each of the offending lines like this: root_entries = (IMAGE_RESOURCE_DIRECTORY_ENTRY*)malloc(sizeof(IMAGE_RESOURCE_DIRECTORY_ENTRY) * (root.NumberOfNamedEntries + root.NumberOfIdEntries)); Or wait until I get around to doing it myself, which will probably take longer.
|
|
jeroen valk
Member #12,087
July 2010
|
Its working now really your the best |
|
GullRaDriel
Member #3,861
September 2003
|
That silly error which isn't one made me ask why to one of our old coding boss. He told me that story: Initially, malloc was returning a (char *) pointer, which, as far as he remember, wasn't guaranteed to have the same size everywhere, hence the cast. So, as Lenny said, this isn't an error in C because (void *) can be casted to whatever pointer you have, but as you saw, the behavior isn't the same in C++. "Code is like shit - it only smells if it is not yours" |
|
jeroen valk
Member #12,087
July 2010
|
well it's working i load them from .egf files the only problem i got now when i load a picture the color changes is this because im using allegro 4.4? ( i see this is because i have to change the background color to 255,0,255 that's why the color changes so if it's possible to change that 255,0,255 to 0,0,0 my problem is over;D) also i got an other question when i have for example a picture and i wanna only have the picture and not the background with the color: 255,0,255 it won't view. |
|
GullRaDriel
Member #3,861
September 2003
|
I don't really understand your questions, anyway what I know is that from the first allegro version I used I was able to make a function which convert colors easily. 1/* function */
2int convert_spr_to_color( BITMAP *spr , int color , int mask )
3{
4 register int x , y ;
5
6 if( !spr )
7 return false ;
8
9 for( x = 0 ; x < spr -> w ; x ++ )
10 {
11 for( y = 0 ; x < spr -> h ; y ++ )
12 {
13 if( _getpixel( spr , x , y ) == mask )
14 _putpixel( spr , x , y , color );
15 }
16 }
17 return true ;
18}
19
20/* use */
21BITMAP *bmp ;
22
23/*
24 ... here you do whatever to fill your bmp with some data ...
25*/
26
27/*converting !*/
28convert_spr_to_color( spr , makecol( 255 , 255 , 255 ) , makecol( 0 , 0 , 0 ) );
Well, untested ! "Code is like shit - it only smells if it is not yours" |
|
LennyLen
Member #5,313
December 2004
|
GullRaDriel said: anyway what I know is that from the first allegro version I used I was able to make a function which convert colors easily The only problem with this approach is that because the background colour is black, any black pixels that aren't part of the background will also be converted. Doing floodfill(bmp, 0, 0, makecol(255, 0, 255)); on each image should do the trick, but will probably be a bit slow and will have odd results on any images that has black pixels along the edge of the background.
|
|
Desmond Taylor
Member #11,943
May 2010
|
This is wy I upgraded to 4.9.20 as it has a built in function to convert to alpha |
|
GullRaDriel
Member #3,861
September 2003
|
A floodfill like Lenny proposed would work. Better in some case (you use pure black in the sprite's body) worse in other (i.e you also have parts to fill inside the body of the sprite). It's really a thing to think before starting to draw. Edit: I also think the OP don't use the right function for displaying his sprites. Just a reminder for him: "Code is like shit - it only smells if it is not yours" |
|
jeroen valk
Member #12,087
July 2010
|
K so with allegro it isnt possible to change that 255,0,255 |
|
GullRaDriel
Member #3,861
September 2003
|
jeroen said: K so with allegro it isnt possible to change that 255,0,255 We never said that ! jeroen said: and if i go to allegro 4.9 it is? I don't know since I don't exactly know what is your problem. Not enough informations. We need:
jeroen said: but if i upgrade to 4.9 will my old code still work? with allegro 4.9??? Not without some major API change in your code, since 4.2/4.4 and 4.9 have very different ones. "Code is like shit - it only smells if it is not yours" |
|
Desmond Taylor
Member #11,943
May 2010
|
I had to make my own function to do this and here is what I did but I now use ALlegro5 so I'm sorry if the code within is wrong. I do know that this is about the same speed of allegro5's built in function so there is no need to change really. 1// Convert a color to allegro alpha.
2void convert_color_to_alpha(BITMAP *bmp, int color)
3{
4 for (int x=0; x<=bmp->w; x++)
5 {
6 for (int y=0; y<=bmp->h; y++)
7 {
8 if (getpixel(bmp, x, y) == color)
9 putpixel(bmp, x, y, makecol(255, 0, 255))
10 }
11 }
12}
13
14// Load the bitmap.
15BITMAP *tile = load_bitmap("tile.bmp", NULL);
16
17// Make black transparent.
18convert_color_to_alpha(tile, makecol(0, 0, 0));
Note: This code is untested but it should work fine |
|
LennyLen
Member #5,313
December 2004
|
Desmond Taylor said: Note: This code is untested but it should work fine Doesn't that make all black pixels in the image transparent then? Or do they just not use black except for the background?
|
|
GullRaDriel
Member #3,861
September 2003
|
Perhaps they use a tiny 1,1,1 black ^^ "Code is like shit - it only smells if it is not yours" |
|
LennyLen
Member #5,313
December 2004
|
GullRaDriel said: Perhaps they use a tiny 1,1,1 black I just checked with a bmp from one of the .egf files I was sent, and they do use 0, 0, 0. I also noticed, while I was checking, that my floodfill idea wouldn't have worked as is. It would take up to 4 floodfills, as there is not a complete border of black around the subject of the picture, as I had believed.
|
|
GullRaDriel
Member #3,861
September 2003
|
Which come down to the following: their sprites aren't suited for that type of display and they're better adapting the existing using their favorite's paint proggy. "Code is like shit - it only smells if it is not yours" |
|
jeroen valk
Member #12,087
July 2010
|
well desmond it's working ^^ only a bit bad i have to do this for each bmp but it's working well :p thx |
|
Desmond Taylor
Member #11,943
May 2010
|
Yea it's 0 0 0 for each image with Endless Online. You would have to call the function all the time. Either call the following with Allegro 4.2.x/4.4.x Or this for allegro 4.9.x 1al_convert_mask_to_alpha(bmp, al_map_rgb(0, 0, 0));
It's still an extra line what ever you do. |
|
jeroen valk
Member #12,087
July 2010
|
Ey also i saw it's not possible to load compressed .egf files but the normal eo client can do this? |
|
LennyLen
Member #5,313
December 2004
|
jeroen valk said: Ey also i saw it's not possible to load compressed .egf files but the normal eo client can do this? If you can provide any info on the format, I could probably add support for it. Until now, I didn't know there were compressed files (I've never played EO myself).
|
|
jeroen valk
Member #12,087
July 2010
|
It's compressed with a .exe compresser |
|
LennyLen
Member #5,313
December 2004
|
jeroen valk said: it's compressed if i'm right it's compressed with a program called PEID PEid is a program for identifying what compressor was used. It failed to detect it for the file you provided.
|
|
|
1
2
|