|
help writing to locked bitmap |
William Labbett
Member #4,486
March 2004
|
Hi guys, I've written some code to merge two black and white bitmaps. The code crashes when I've done some detective work but not found out what's wrong. The bad code is somewhere near the end this code : 1int merge_black_and_white(ALLEGRO_CONFIG *cfg)
2{
3 unsigned char mr, mg, mb; /* */
4 ALLEGRO_BITMAP *bw1;
5 ALLEGRO_BITMAP *bw2;
6 const char *bw1_name;
7 const char *bw2_name;
8 const char *config_string;
9 ALLEGRO_LOCKED_REGION *lock1;
10 ALLEGRO_LOCKED_REGION *lock2;
11 ALLEGRO_LOCKED_REGION *lock3;
12 ALLEGRO_BITMAP *output;
13 int blend_type;
14 int x, y;
15 unsigned char *ptr1, *ptr2, *ptr3;
16 int r1, g1, b1, r2, g2, b2, a1, a2;
17 unsigned char new_r, new_g, new_b;
18 unsigned char new_gray;
19
20 uint32_t new_colour;
21
22
23 /***** Load the first black and white bitmap. *****************************************/
24
25 bw1_name = al_get_config_value( cfg, NULL, "bw_picture1" );
26 if(bw1_name == NULL)
27 {
28 cout << "No value for \"bw_picture1\" in config file.\n";
29 eek();
30 }
31 else
32 {
33 cout << "Name of bitmap 1 is " << bw1_name << "\n\n";
34 }
35
36
37 cout << "Attempting to load " << bw1_name << "\n\n";
38
39 bw1 = al_load_bitmap(bw1_name);
40
41 if(bw1 == NULL)
42 {
43 cout << "Loading failed.\n";
44 eek();
45 }
46 else
47 {
48 cout << "Loaded it.\n";
49 }
50
51 /***** Load the second black and white bitmap. ****************************************/
52
53
54 bw2_name = al_get_config_value( cfg, NULL, "bw_picture2");
55 if( bw2_name == NULL )
56 {
57 cout << "No value for \"bw_picture2\" in config file.\n";
58 eek();
59 }
60 else
61 {
62 cout << "Name of bitmap 2 is " << bw2_name << "\n\n";
63 }
64
65 cout << "Attempting to load " << bw2_name << "\n\n";
66
67 bw2 = al_load_bitmap( bw2_name );
68
69 if(bw2 == NULL)
70 {
71 cout << "Loading failed.\n";
72 return 1;
73 }
74 else
75 {
76 cout << "Loaded it.\n";
77 }
78
79 /*********************************************************************************************/
80
81
82
83 int bw = al_get_bitmap_width( bw1 );
84 int bh = al_get_bitmap_height( bw1 );
85
86 if( bw != al_get_bitmap_width(bw2) || bh != al_get_bitmap_height(bw2) )
87 {
88
89 cout << "Bitmaps are not the same dimensions.\n";
90
91 return 1;
92 }
93 else
94 {
95 cout << "bw1 : " << bw << " * " << bh << "\n\n bw2 : " << al_get_bitmap_width(bw2) << " * " << al_get_bitmap_height(bw2) << "\n\n";
96 }
97
98
99 output = al_create_bitmap( bw, bh );
100
101 if(output == NULL)
102 {
103 cout << "couldn't create the output bitmap.\n";
104 return 1;
105 }
106
107
108 lock1 = al_lock_bitmap( bw1, ALLEGRO_PIXEL_FORMAT_RGBA_8888, ALLEGRO_LOCK_READONLY );
109
110 if(lock1 == NULL)
111 {
112 cout << "Couldn't lock bitmap 1.\n";
113 return 1;
114 }
115
116 cout << " locked bitmap 1.\n\n";
117
118 lock2 = al_lock_bitmap( bw2, ALLEGRO_PIXEL_FORMAT_RGBA_8888, ALLEGRO_LOCK_READONLY );
119
120 if(lock2 == NULL)
121 {
122 cout << "Couldn't lock bitmap 1.\n";
123 return 1;
124 }
125
126 cout << " locked bitmap 2.\n\n";
127
128
129
130 output = al_create_bitmap( bw, bh );
131 if(output == NULL)
132 {
133 cout << "Couldn't create the new bitmap.\n";
134 return 1;
135 }
136
137
138
139
140 cout << "Getting blend type.\n";
141
142 /* Using bw1_name out of context here instead of using another variable. */
143
144 bw1_name = al_get_config_value( cfg, NULL, "black_and_white_merge_blend_type" );
145
146
147 if( strcmp( bw1_name, "average" ) == 0 )
148 {
149 blend_type = BLEND_MODE_AVERAGE;
150 }
151 else if( strcmp( bw1_name, "darkest" ) == 0 )
152 {
153 blend_type = BLEND_MODE_DARKEST;
154 }
155 else
156 {
157 cout << "No blend mode specified in configuration file.\n\n";
158 return 1;
159 }
160
161
162 lock3 = al_lock_bitmap( output, ALLEGRO_PIXEL_FORMAT_RGBA_8888, ALLEGRO_LOCK_WRITEONLY );
163 if(lock3 == NULL)
164 {
165 cout << "Couldn't lock output bitmap.\n\n";
166 return 1;
167 }
168
169 /***************************************************************************************************/
170 /****************** Get the colour which is the mask colour. ***************************************/
171 /***************************************************************************************************/
172
173
174 if( get_mask_colour(cfg, &mr, &mg, &mb) != 0 )
175 {
176 cout << "Couldn't get mask colour from configuration file.\n\n";
177 return 1;
178 }
179
180 /***************************************************************************************************/
181
182 cout << "processing bitmaps.\n\n";
183
184 for( y = 0; y < bh; ++y )
185 {
186 for( x = 0; x < bw; ++x )
187 {
188 cout << "y = " << y << "x = " << x << "\n\n";
189 ptr1 = ((unsigned char *) lock1) + lock1->pitch * y + x * 4;
190 ptr2 = ((unsigned char *) lock2) + lock2->pitch * y + x * 4;
191
192 ptr3 = ((unsigned char *) lock3) + lock3->pitch * y + x * 4;
193
194 //cout << "got pointers.\n\n";
195
196 r1 = (int) *(ptr1 + 3);
197 g1 = (int) *(ptr1 + 2);
198 b1 = (int) *(ptr1 + 1);
199 a1 = (int) *(ptr1 + 0);
200
201 r2 = (int) *(ptr2 + 3);
202 g2 = (int) *(ptr2 + 2);
203 b2 = (int) *(ptr2 + 1);
204 a2 = (int) *(ptr2 + 0);
205
206 /*
207 if(a1 != 255 || a2 != 255)
208 {
209 cout << "Alpha of at least one pixel on bitmap is not 255. Aborting in case this matters.\n\n";
210 cout << "x = " << x << "y = " << y << " a1 = " << a1 << " a2 = " << a2 << "\n\n";
211 return 1;
212 }
213 else
214 *
215 */
216 /*
217 if( (r1 != g1 || g1 != b1 || r1 != b1) )
218 {
219 cout << "A pixel on bitmap 1 is not grey.\n\n";
220 return 1;
221 }
222 else if( (r2 != g2 || g2 != b2 || r2 != b2) )
223 {
224 cout << "A pixel on bitmap 2 is not grey.\n\n";
225 return 1;
226 }
227 */
228
229 switch(blend_type)
230 {
231 case BLEND_MODE_AVERAGE:
232
233 new_gray = (unsigned char) ((((float) r1 + (float) r2) / 2.0) + 0.5);
234
235 break;
236 case BLEND_MODE_DARKEST:
237
238 new_gray = (unsigned char) (r1 > r2) ? r1 : r2;
239
240 break;
241 }
242
243 new_colour = ((new_gray) << 24) | ((new_gray) << 16) | ((new_gray) << 8) | 255;
244
245
246 if( (r1 == mr && g1 == mg && b1 == mb) || (r2 == mr && g2 == mg && b2 == mb) )
247 {
248 /* Put */
249
250 cout << "white.\n";
251 *((uint32_t *) ptr3) = 0xffffffff;
252 }
253 else
254 {
255 cout << "grey.\n";
256 *((uint32_t *) ptr3) = new_colour;
257 }
258 }
259 }
260
261 cout << "unlocking bitmaps.\n";
262
263
264 al_unlock_bitmap( bw1 );
265 al_unlock_bitmap( bw2 );
266 al_unlock_bitmap( output );
267
268
269
270 al_save_bitmap("output.png", output);
271
272}
|
ph03nix
Member #15,028
April 2013
|
I just skimmed over, but two things caught my eye: lock3 = al_lock_bitmap( output, ALLEGRO_PIXEL_FORMAT_RGBA_8888, ALLEGRO_LOCK_WRITEONLY ); if you are reading and writing to the bitmap, shouldn't you use ALLEGRO_LOCK_READWRITE? Not sure if that's causing the crash. Also, this at the end: *((uint32_t *) ptr3) = 0xffffffff; It seems like you're setting the alpha to the combined value of the colour. It should be more like: *((uint32_t *) ptr3) = 0xff; //a *((uint32_t *) ptr3+1) = 0xff; //b *((uint32_t *) ptr3+2) = 0xff; //g *((uint32_t *) ptr3+3) = 0xff; //r What I think is happening is that the value you set for the pixel is out of range, causing the crash. |
Trent Gamblin
Member #261
April 2000
|
ph03nix said: Also, this at the end: *((uint32_t *) ptr3) = 0xffffffff; It's perfectly ok to do that. That would set the pixel to white. I'm not sure what the problem is William, did you try running it through a debugger?
|
ph03nix
Member #15,028
April 2013
|
Doesn't that set the value of the array at position ptr3 to 0xffffffff (4294967295)? Let's say I actually wanted to set unsigned char at that position to that value, that's how I would do it, right? (although it would become 0 or something) |
Trent Gamblin
Member #261
April 2000
|
Yeah that's what it does. This: unsigned char *ptr; *((uint32_t *)ptr) = 0xaabbccdd; Is identical to this: unsigned char *ptr; *(ptr+0) = 0xdd; *(ptr+1) = 0xcc; *(ptr+2) = 0xbb; *(ptr+3) = 0xaa;
|
ph03nix
Member #15,028
April 2013
|
I wrote this test code: unsigned char* test = new unsigned char[4]; test[0]=0; test[1]=0; test[2]=0; test[3]=0; *((unsigned char*)test) = 0xffffffff; std::cout<<(int)test[0]<<", "<<(int)test[1]<<", "<<(int)test[2]<<", "<<(int)test[3]<<std::endl; delete []test; and the output was 255, 0, 0, 0 |
Trent Gamblin
Member #261
April 2000
|
That's because you casted to unsigned char instead of uint32_t.
|
ph03nix
Member #15,028
April 2013
|
Oh, I see now... |
William Labbett
Member #4,486
March 2004
|
Program received signal SIGSEGV, Segmentation fault. I've rewritten the code a bit : 1int merge_black_and_white(ALLEGRO_CONFIG *cfg)
2{
3 unsigned char mr, mg, mb; /* */
4 ALLEGRO_BITMAP *bw1;
5 ALLEGRO_BITMAP *bw2;
6 const char *bw1_name;
7 const char *bw2_name;
8 const char *config_string;
9 ALLEGRO_LOCKED_REGION *lock1;
10 ALLEGRO_LOCKED_REGION *lock2;
11 ALLEGRO_LOCKED_REGION *lock3;
12 ALLEGRO_BITMAP *output;
13 int blend_type;
14 int x, y;
15 unsigned char *ptr1, *ptr2, *ptr3;
16 int r1, g1, b1, r2, g2, b2, a1, a2;
17 unsigned char new_r, new_g, new_b;
18 unsigned char new_gray;
19
20 uint32_t new_colour;
21
22
23 /***** Load the first black and white bitmap. *****************************************/
24
25 bw1_name = al_get_config_value( cfg, NULL, "bw_picture1" );
26 if(bw1_name == NULL)
27 {
28 cout << "No value for \"bw_picture1\" in config file.\n";
29 eek();
30 }
31 else
32 {
33 cout << "Name of bitmap 1 is " << bw1_name << "\n\n";
34 }
35
36
37 cout << "Attempting to load " << bw1_name << "\n\n";
38
39 bw1 = al_load_bitmap(bw1_name);
40
41 if(bw1 == NULL)
42 {
43 cout << "Loading failed.\n";
44 eek();
45 }
46 else
47 {
48 cout << "Loaded it.\n";
49 }
50
51 /***** Load the second black and white bitmap. ****************************************/
52
53
54 bw2_name = al_get_config_value( cfg, NULL, "bw_picture2");
55 if( bw2_name == NULL )
56 {
57 cout << "No value for \"bw_picture2\" in config file.\n";
58 eek();
59 }
60 else
61 {
62 cout << "Name of bitmap 2 is " << bw2_name << "\n\n";
63 }
64
65 cout << "Attempting to load " << bw2_name << "\n\n";
66
67 bw2 = al_load_bitmap( bw2_name );
68
69 if(bw2 == NULL)
70 {
71 cout << "Loading failed.\n";
72 return 1;
73 }
74 else
75 {
76 cout << "Loaded it.\n";
77 }
78
79 /*********************************************************************************************/
80
81
82
83 int bw = al_get_bitmap_width( bw1 );
84 int bh = al_get_bitmap_height( bw1 );
85
86 if( bw != al_get_bitmap_width(bw2) || bh != al_get_bitmap_height(bw2) )
87 {
88
89 cout << "Bitmaps are not the same dimensions.\n";
90
91 return 1;
92 }
93 else
94 {
95 cout << "bw1 : " << bw << " * " << bh << "\n\n bw2 : " << al_get_bitmap_width(bw2) << " * " << al_get_bitmap_height(bw2) << "\n\n";
96 }
97
98
99
100
101
102 lock1 = al_lock_bitmap( bw1, ALLEGRO_PIXEL_FORMAT_RGBA_8888, ALLEGRO_LOCK_READONLY );
103
104 if(lock1 == NULL)
105 {
106 cout << "Couldn't lock bitmap 1.\n";
107 return 1;
108 }
109
110 cout << " locked bitmap 1.\n\n";
111
112 lock2 = al_lock_bitmap( bw2, ALLEGRO_PIXEL_FORMAT_RGBA_8888, ALLEGRO_LOCK_READONLY );
113
114 if(lock2 == NULL)
115 {
116 cout << "Couldn't lock bitmap 1.\n";
117 return 1;
118 }
119
120 cout << " locked bitmap 2.\n\n";
121
122
123
124
125 output = al_create_bitmap( bw, bh );
126 if(output == NULL)
127 {
128 cout << "Couldn't create the new bitmap.\n";
129 return 1;
130 }
131
132
133 cout << "output bitmap : " << al_get_bitmap_width(output) << " * " << al_get_bitmap_height(output) << "\n\n";
134
135 cout << "Getting blend type.\n";
136
137 /* Using bw1_name out of context here instead of using another variable. */
138
139 bw1_name = al_get_config_value( cfg, NULL, "black_and_white_merge_blend_type" );
140
141
142 if( strcmp( bw1_name, "average" ) == 0 )
143 {
144 blend_type = BLEND_MODE_AVERAGE;
145 }
146 else if( strcmp( bw1_name, "darkest" ) == 0 )
147 {
148 blend_type = BLEND_MODE_DARKEST;
149 }
150 else
151 {
152 cout << "No blend mode specified in configuration file.\n\n";
153 return 1;
154 }
155
156
157 lock3 = al_lock_bitmap( output, ALLEGRO_PIXEL_FORMAT_RGBA_8888, ALLEGRO_LOCK_READWRITE );
158 if(lock3 == NULL)
159 {
160 cout << "Couldn't lock output bitmap.\n\n";
161 return 1;
162 }
163
164 /***************************************************************************************************/
165 /****************** Get the colour which is the mask colour. ***************************************/
166 /***************************************************************************************************/
167
168
169 if( get_mask_colour(cfg, &mr, &mg, &mb) != 0 )
170 {
171 cout << "Couldn't get mask colour from configuration file.\n\n";
172 return 1;
173 }
174
175 /***************************************************************************************************/
176
177 cout << "processing bitmaps.\n\n";
178
179 for( y = 0; y < bh; ++y )
180 {
181 for( x = 0; x < bw; ++x )
182 {
183 //cout << "y = " << y << "x = " << x << "\n\n";
184 ptr1 = ((unsigned char *) lock1) + lock1->pitch * y + x * 4;
185 ptr2 = ((unsigned char *) lock2) + lock2->pitch * y + x * 4;
186
187 ptr3 = ((unsigned char *) lock3) + lock3->pitch * y + x * 4;
188
189 //cout << "got pointers.\n\n";
190
191 r1 = (int) *(ptr1 + 3);
192 g1 = (int) *(ptr1 + 2);
193 b1 = (int) *(ptr1 + 1);
194 a1 = (int) *(ptr1 + 0);
195
196 r2 = (int) *(ptr2 + 3);
197 g2 = (int) *(ptr2 + 2);
198 b2 = (int) *(ptr2 + 1);
199 a2 = (int) *(ptr2 + 0);
200
201 /*
202 if(a1 != 255 || a2 != 255)
203 {
204 cout << "Alpha of at least one pixel on bitmap is not 255. Aborting in case this matters.\n\n";
205 cout << "x = " << x << "y = " << y << " a1 = " << a1 << " a2 = " << a2 << "\n\n";
206 return 1;
207 }
208 else
209 *
210 */
211 /*
212 if( (r1 != g1 || g1 != b1 || r1 != b1) )
213 {
214 cout << "A pixel on bitmap 1 is not grey.\n\n";
215 return 1;
216 }
217 else if( (r2 != g2 || g2 != b2 || r2 != b2) )
218 {
219 cout << "A pixel on bitmap 2 is not grey.\n\n";
220 return 1;
221 }
222 */
223
224 switch(blend_type)
225 {
226 case BLEND_MODE_AVERAGE:
227
228 new_gray = (unsigned char) ((((float) r1 + (float) r2) / 2.0) + 0.5);
229
230 break;
231 case BLEND_MODE_DARKEST:
232
233 new_gray = (unsigned char) (r1 > r2) ? r1 : r2;
234
235 break;
236 }
237
238 //cout << "new_gray = " << (int) new_gray << "\n";
239
240 new_colour = ((new_gray) << 24) | ((new_gray) << 16) | ((new_gray) << 8) | 255;
241
242
243 if( (r1 == mr && g1 == mg && b1 == mb) || (r2 == mr && g2 == mg && b2 == mb) )
244 {
245 /* Put */
246
247 //cout << "white.\n";
248 *((uint32_t *) ptr3) = 0xffffffff;
249 }
250 else
251 {
252 //cout << "grey.\n";
253 //cout << "x = " << x << "y = " << y << "\n\n";
254 *((uint32_t *) ptr3) = new_colour;
255 }
256 }
257 }
258
259 cout << "unlocking bitmaps.\n";
260
261
262 al_unlock_bitmap( bw1 );
263 al_unlock_bitmap( bw2 );
264 al_unlock_bitmap( output );
265
266
267
268 al_save_bitmap("output.png", output);
269
270}
|
Trent Gamblin
Member #261
April 2000
|
The symbol name suggests it's crashing in cout. Compile with debugging (use -g command line switch to gcc/g++). Then try again, it should tell you a line number. Also run "bt" in gdb after it crashes.
|
William Labbett
Member #4,486
March 2004
|
g++ colourer.cpp shade_coloured_picture.cpp merge_black_and_white.cpp text_output_management.cpp -o colourer.exe -lallegro-5.0.5-monolith-md Where do I put the -g in this line please ?
|
Trent Gamblin
Member #261
April 2000
|
Doesn't really matter, but let's just say "g++ -g ..." .
|
William Labbett
Member #4,486
March 2004
|
Thanks. Got some better output :- Program received signal SIGSEGV, Segmentation fault.
|
Trent Gamblin
Member #261
April 2000
|
So that means line 228 in merge_black_and_white.cpp is what's crashing. Is that what we're looking at? If so I don't think your code listing is up to date because that's not what line 228 looks like. EDIT: make sure your code and executable are matching.
|
William Labbett
Member #4,486
March 2004
|
Okay. nm the code so far. This code : 1cout << "pitch members of locks :";
2 cout << "lock1->pitch = " << lock1->pitch << "\n";
3 cout << "lock2->pitch = " << lock2->pitch << "\n";
4 cout << "lock3->pitch = " << lock3->pitch << "\n";
5
6 /***************************************************************************************************/
7 /****************** Get the colour which is the mask colour. ***************************************/
8 /***************************************************************************************************/
9
10
11 if( get_mask_colour(cfg, &mr, &mg, &mb) != 0 )
12 {
13 cout << "Couldn't get mask colour from configuration file.\n\n";
14 return 1;
15 }
16
17 /***************************************************************************************************/
18
19 cout << "processing bitmaps.\n\n";
20
21 for( y = 0; y < bh; ++y )
22 {
23 for( x = 0; x < bw; ++x )
24 {
25 //cout << "y = " << y << "x = " << x << "\n\n";
26
27 if(x > al_get_bitmap_width(output))
28 {
29 cout << "problem 1000.\n";
30 return 1;
31 }
32
33 if(x >= lock1->pitch)
34 {
35 cout << "x outside bitmap (1).\n";
36 return 1;
37 }
38
39 if(x >= lock2->pitch)
40 {
41 cout << "x outside bitmap (2).\n";
42 return 1;
43 }
44
45 if(x >= lock3->pitch)
46 {
47 cout << "x outside bitmap (3).\n";
48
49 cout << "pitch of lock3 is " << lock3->pitch << " x is " << x << "\n\n";
50
51 return 1;
52 }
53
54
55 ptr1 = ((unsigned char *) lock1) + lock1->pitch * y + x * 4;
56 ptr2 = ((unsigned char *) lock2) + lock2->pitch * y + x * 4;
57 ptr3 = ((unsigned char *) lock3) + lock3->pitch * y + x * 4;
58
59
60 r1 = (int) *(ptr1 + 3);
61 g1 = (int) *(ptr1 + 2);
62 b1 = (int) *(ptr1 + 1);
63 a1 = (int) *(ptr1 + 0);
64
65 r2 = (int) *(ptr2 + 3);
66 g2 = (int) *(ptr2 + 2);
67 b2 = (int) *(ptr2 + 1);
68 a2 = (int) *(ptr2 + 0);
69
70 /*
71 if(a1 != 255 || a2 != 255)
72 {
73 cout << "Alpha of at least one pixel on bitmap is not 255. Aborting in case this matters.\n\n";
74 cout << "x = " << x << "y = " << y << " a1 = " << a1 << " a2 = " << a2 << "\n\n";
75 return 1;
76 }
77 else
78 *
79 */
80 /*
81 if( (r1 != g1 || g1 != b1 || r1 != b1) )
82 {
83 cout << "A pixel on bitmap 1 is not grey.\n\n";
84 return 1;
85 }
86 else if( (r2 != g2 || g2 != b2 || r2 != b2) )
87 {
88 cout << "A pixel on bitmap 2 is not grey.\n\n";
89 return 1;
90 }
91 */
92
93 switch(blend_type)
94 {
95 case BLEND_MODE_AVERAGE:
96
97 new_gray = (unsigned char) ((((float) r1 + (float) r2) / 2.0) + 0.5);
98
99 break;
100 case BLEND_MODE_DARKEST:
101
102 new_gray = (unsigned char) (r1 > r2) ? r1 : r2;
103
104 break;
105 }
106
107 //cout << "new_gray = " << (int) new_gray << "\n";
108
109 new_colour = ((new_gray) << 24) | ((new_gray) << 16) | ((new_gray) << 8) | 255;
110
111
112 if( (r1 == mr && g1 == mg && b1 == mb) || (r2 == mr && g2 == mg && b2 == mb) )
113 {
114 /* Put */
115
116 //cout << "white.\n";
117 *((uint32_t *) ptr3) = 0xffffffff;
118 }
119 else
120 {
121
122 *((uint32_t *) ptr3) = new_colour;
123 }
124 }
125 }
126
127 cout << "unlocking bitmaps.\n";
128
129
130 al_unlock_bitmap( bw1 );
131 al_unlock_bitmap( bw2 );
132 al_unlock_bitmap( output );
...gives this output :- 1Name of bitmap 1 is tree1_bw.png
2
3Attempting to load tree1_bw.png
4
5[New Thread 4644.0xa6c]
6Loaded it.
7Name of bitmap 2 is tree2_bw.png
8
9Attempting to load tree2_bw.png
10
11Loaded it.
12bw1 : 1938 * 3486
13
14 bw2 : 1938 * 3486
15
16 locked bitmap 1.
17
18 locked bitmap 2.
19
20output bitmap : 1938 * 3486
21
22Getting blend type.
23pitch members of locks :lock1->pitch = 7752
24lock2->pitch = 7752
25lock3->pitch = 7752
26processing bitmaps.
27
28x outside bitmap (3).
29pitch of lock3 is 255 x is 255
30
31Press any key to continue . . .
32Program received signal SIGSEGV, Segmentation fault.
Which means the pitch of lock3 is changed to 255 at some point. Any ideas what this could be ? Memory corruption ? EDIT : Would this do anything :- #include <stdint.h>
It's at the top of the source file. #include <cstdint>
..but the compiler complained.
|
Trent Gamblin
Member #261
April 2000
|
Oop! I didn't notice this... instead of using ((unsigned char *)lock1) etc, use lock1->data.
|
William Labbett
Member #4,486
March 2004
|
Many thanks Trent!
|
|