|
Cannot lock target bitmap |
damianday
Member #14,620
October 2012
|
Hello I am trying to read pixels from the target bitmap (al_get_target_bitmap), by locking it. Unfortunately locking always fails. So I tried cloning the target bitmap and then locking the clone, this also fails I need to read the target bitmap before saving it to a file, is there any other way I can do this? SOLVED - SEE POST FOR SOLUTION |
Elias
Member #358
May 2000
|
Post the code. -- |
damianday
Member #14,620
October 2012
|
1procedure TGame.TakeScreenShot;
2var
3 i, checksum: integer;
4 flname: string;
5 zcopy: PAnsiChar;
6
7 bmp: PAllegroBitmap;
8 format: ALLEGRO_PIXEL_FORMAT;
9 lr: PAllegroLockedRegion;
10begin
11 bmp := al_get_target_bitmap;
12 if bmp = nil then Exit;
13 format := al_get_bitmap_format(bmp);
14
15 flname := 'Screenshot.bmp';
16 zcopy := PAnsiChar(AnsiString(flname));
17
18 checksum := 0;
19 try
20 lr := al_lock_bitmap(bmp, format, ALLEGRO_LOCK_READONLY);
21 if lr = nil then Exit;
22
23 // Note: Never reach this point lr is always nil..
24 for i := (SCREENHEIGHT - 200) to SCREENHEIGHT - 1 do begin
25 // TODO: calculate checksum with lr.data
26
27 end;
28 finally
29 al_unlock_bitmap(bmp);
30 end;
31
32 al_save_bitmap(zcopy, bmp);
33end;
|
Elias
Member #358
May 2000
|
Can you lock other bitmaps? -- |
damianday
Member #14,620
October 2012
|
Yes I've just tested and there is no problems with On a side note I'm using Allegro 5.0.7 until 5.1 is stable. Curiously this case works fine in a simple test project, but not in my main, I think it could be a bug in my code somewhere.. Ok I've tracked it down to: 1al_set_new_display_option(ALLEGRO_DISPLAY_OPTIONS.ALLEGRO_SAMPLE_BUFFERS, 1, ALLEGRO_SUGGEST);
2al_set_new_display_option(ALLEGRO_DISPLAY_OPTIONS.ALLEGRO_SAMPLES, 8, ALLEGRO_SUGGEST);
Commenting these lines out makes it go away |
Elias
Member #358
May 2000
|
Intersting to know. Are you using DirectX? I don't think multi-sampling should prevent reading the backbuffer, in general. -- |
damianday
Member #14,620
October 2012
|
I'm just using vanilla Allegro code on Windows 7 X64, It seems the code below creates the bug in question. 1al_set_new_display_option(ALLEGRO_DISPLAY_OPTIONS.ALLEGRO_SAMPLE_BUFFERS, 1, ALLEGRO_SUGGEST);
2 al_set_new_display_option(ALLEGRO_DISPLAY_OPTIONS.ALLEGRO_SAMPLES, 8, ALLEGRO_SUGGEST);
|
J-Gamer
Member #12,491
January 2011
|
Allegro uses DirectX by default on Windows. " There are plenty of wonderful ideas in The Bible, but God isn't one of them." - Derezo |
damianday
Member #14,620
October 2012
|
Is there a way to override this behaviour and make it use opengl? |
|