![]() |
|
This thread is locked; no one can reply to it.
![]() ![]() |
1
2
|
PNG files? |
David Sopala
Member #5,056
September 2004
|
Still failing to load image correctly - I did use one of your sprites. I know my working path is right because I have loaded a couple .bmps from the same folder. My test code follows maybe I am doing something wrong? 1#include <winalleg.h>
2#include <loadpng.h>
3#include <zlib.h>
4
5#include <fstream>
6
7#include <conio.h>
8#include <string.h>
9using namespace std;
10
11//FONT *big_font = NULL;
12int volume;
13const int scrx = 1024;
14const int scry = 768;
15BITMAP *target;
16BITMAP *BUFFER;
17bool insidecircle(int tx,int ty,int x,int y,int rad);
18void ini();
19bool keyrel(int k);
20
21RGB* my_palette;
22COLOR_MAP global_trans_table;
23ofstream out;
24
25int main()
26{
27
28
29 ini();
30 target = NULL;
31 out<<"Loading png filetype"<<endl;
32 target = load_bitmap("0.png",NULL);
33 out<<"Target : "<<target<<endl
34 <<"Target &: "<<target<<endl;
35 if(!target)allegro_message("Failed to load image");
36 while(!key[KEY_ESC])
37 {
38 drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
39 set_alpha_blender();
40 if(target)draw_trans_sprite(screen, target, 64, 64);
41 // ... draw more translucent bitmaps
42 solid_mode();
43 //blit(BUFFER,screen,0,0,0,0,scrx,scry);
44
45 }
46
47 return 0;
48}
49END_OF_MAIN()
50
51void ini()
52{
53 out.open("log.txt");
54 if (allegro_init())
55 {
56 allegro_message("Cannot initalize Allegro. Quiting\n");
57 exit(101);
58 }
59 //Set the window title when in a GUI environment
60 set_window_title("PNG test draw");
61
62 if (install_keyboard())
63 {
64 allegro_message("ERROR: Cannot initalize keyboard input. Quiting\n");
65 exit(102);
66 }
67
68 if (!install_mouse())
69 {
70 allegro_message("ERROR: Cannot initalize mouse input. Quiting\n");
71 exit(103);
72 }
73 install_timer();
74 install_sound(DIGI_AUTODETECT, MIDI_AUTODETECT, NULL);
75 //DATAFILE * d=load_datafile("comic.dat");
76 //if (d)
77 //{
78 //big_font = (FONT*)d[0].dat;
79 //}
80 set_mouse_sprite(NULL);
81 //set graphics mode, trying all acceptable depths 1024x768
82 set_color_depth(32);
83 if (set_gfx_mode(GFX_AUTODETECT, scrx, scry, 0, 0)) {
84 set_color_depth(24);
85 if (set_gfx_mode(GFX_AUTODETECT, scrx, scry, 0, 0)) {
86 set_color_depth(16);
87 if (set_gfx_mode(GFX_AUTODETECT, scrx, scry, 0, 0)) {
88 set_color_depth(15);
89 if (set_gfx_mode(GFX_AUTODETECT, scrx, scry, 0, 0)) {
90 allegro_message("Video Error: %s.\n", allegro_error);
91 exit(1);
92 }
93 }
94 }
95 }
96 out<<"REGISTERING PNG FILETYPE"<<endl;
97 register_png_file_type();
98 out<<"REGISTRATION SUCCESSFUL"<<endl;
99
100 out<<"Creating trans table"<<endl;
101 my_palette = new PALETTE;
102 create_trans_table(&global_trans_table, my_palette,128, 128, 128, NULL);
103 out<<"Color depth is "<<get_color_depth()<<endl;
104 if (get_color_depth() == 8)
105 {
106 color_map = &global_trans_table;
107 }
108
109 else
110 {
111 set_trans_blender(128, 128, 128, 128);
112 }
113 out<<"Leaving ini()"<<endl;
114
115}
OUTPUT: REGISTERING PNG FILETYPE REGISTRATION SUCCESSFUL Creating trans table Color depth is 32 Leaving ini() Loading png filetype Target : 0 Target &: 0
<img src="http://imgur.com/bfHvGkj.jpg" /> |
GullRaDriel
Member #3,861
September 2003
![]() |
/* That line means that 0.png is in the same directory as the executable trying to laod it*/ target = load_bitmap("0.png",NULL); /* these two one will print the same thing two times no matter what the value is.*/ out<<"Target : "<<target<<endl <<"Target &: "<<target<<endl;
"Code is like shit - it only smells if it is not yours" |
LennyLen
Member #5,313
December 2004
![]() |
Try the most basic test example and see if that produces the same result. eg: 1#include <allegro.h>
2#include <loadpng.h>
3
4int main() {
5
6 allegro_init();
7 install_keyboard();
8 set_color_depth(32);
9 set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0);
10
11 register_png_file_type();
12 BITMAP *bmp = load_bitmap("0.png", NULL);
13 if(!bmp) {
14 allegro_message("Error opening image.");
15 exit(-1);
16 }
17
18 blit(bmp, screen, 0, 0, 0, 0, bmp->w, bmp->h);
19
20 readkey();
21
22 return 0;
23
24}
25END_OF_MAIN()
I couldn't check that code myself as there isn't even a compiler installed on this machine.
|
David Sopala
Member #5,056
September 2004
|
@GullRaDriel I already said it was in the directory. Please read all the posts before quick posting bs that still has no bearing on the situation. 1Directory of C:\Users\XXXXX\Desktop\png test draws\png test draw\bin\Debug
2
309/22/2011 06:23 AM <DIR> .
409/22/2011 06:23 AM <DIR> ..
504/10/2010 11:04 AM 3,503 0.png
604/09/2010 11:24 PM 2,354,267 alld42.dll
704/09/2010 11:24 PM 566,399 alleg42.dll
808/27/2011 09:23 PM 989,740 allegro-4.4.2-md.dll
904/09/2010 11:24 PM 1,062,974 allp42.dll
1009/20/2011 10:09 PM 43,008 libgcc_s_dw2-1.dll
1108/27/2011 09:23 PM 258,796 loadpng-1.5-md.dll
1209/22/2011 06:23 AM 155 log.txt
1309/22/2011 06:23 AM 925,206 png test draw.exe
1409/20/2011 06:40 PM 16,889,526 sidewalk_pavement_texture_01.bmp
1509/19/2011 04:18 PM 6,182 spider.png
1609/20/2011 06:27 PM 12,342 spider256_magic_pink.bmp
17 12 File(s) 23,112,098 bytes
18 2 Dir(s) 280,725,102,592 bytes free
@LennyLen linker settings linker libs <img src="http://imgur.com/bfHvGkj.jpg" /> |
Edgar Reynaldo
Major Reynaldo
May 2007
![]() |
Right click on your 0.png file and look at it's properties. It might have a clue. After that, try loading it in an image editor and see if that works. If it does, try saving it again under a different name. See if there are any properties about it that you can change. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
David Sopala
Member #5,056
September 2004
|
Nothing I can change other than make it hidden or read-only, windows says it is ready for archiving, and Allow this file to have contents indexed in addition to file properties. Pulled it straight from the zip I got off lenny(which worked for him). <img src="http://imgur.com/bfHvGkj.jpg" /> |
Edgar Reynaldo
Major Reynaldo
May 2007
![]() |
Did you make sure your current working directory is correct like I showed you earlier? My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
David Sopala
Member #5,056
September 2004
|
It is correct because if I load an actual .bmp file it loads and displays just fine. Only having issues with the .png extention. <img src="http://imgur.com/bfHvGkj.jpg" /> |
Edgar Reynaldo
Major Reynaldo
May 2007
![]() |
Attach your 0.png file so others can test if it works for them. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
David Sopala
Member #5,056
September 2004
|
There yea go. <img src="http://imgur.com/bfHvGkj.jpg" /> |
Edgar Reynaldo
Major Reynaldo
May 2007
![]() |
Well, there's nothing wrong with the file, because loading it with allegro works for me. What version of allegro / loadpng / zlib are you using? Are you using the binary distribution from a.cc? My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
David Sopala
Member #5,056
September 2004
|
Binarys from a.cc only place I go for allegro's distribution. I have allegro 4.4 I believe I will need to check Just did a reinstall of all the updated versions of everything(to my knowledge) Code::blocks 10.5 zlib-1.2.3 libpng-1.2.37 allegro-5.0.4-mingw-4.5.2 So, I have installed the packages from sourceforge.com.... <img src="http://imgur.com/bfHvGkj.jpg" /> |
Oscar Giner
Member #2,207
April 2002
![]() |
Allegro 5 is a completely different lib. So unless you want to learn it and port your current project to it, use the latest Allegro 4. -- |
David Sopala
Member #5,056
September 2004
|
Yea I noticed, at the same time I also understand it has png built in correct? One hell of a static link list though... although the walkthrough I found on it gave a good list I seem to be missing one fule, but thats for another topic. Since my server does not use any allegro code at all I think I can manage to code the client in allegro 5 and take advantage of the new hardware acceleration. <img src="http://imgur.com/bfHvGkj.jpg" /> |
GullRaDriel
Member #3,861
September 2003
![]() |
David said: @GullRaDriel I already said it was in the directory. Please read all the posts before quick posting bs that still has no bearing on the situation.
I didn't said BullShit. All I did was spotting 2 evidences. Obvious for the first maybe. What else ? Keep cool when you talk to guys trying to help you. I also would have kicked your back, but you're too far away, bullshiter ! Else, have a nice day. "Code is like shit - it only smells if it is not yours" |
|
1
2
|