Le 20/11/2011 09:39, Hartmut Schirmer a écrit :
Hi,
not sure if it's compatible but FreePascal implementation of getImage has
Bitmap[0] := X2-X1+1; { First longint is width } Bitmap[1] := Y2-Y1+1; { Second longint is height } Bitmap[2] := 0; { Third longint is reserved} Bitmap[i] := getPixel(...)
It is nearly what is said in the BP help --------------------------------------------------------------------------- Declaration: function ImageSize(x1, y1, x2, y2: Integer): Word;
Target: Real, Protected
Remarks: X1, Y1, X2, and Y2 define a rectangular region on the screen. ImageSize determines the number of bytes necessary for GetImage to save the specified region of the screen. The image size includes space for three words. The first stores the width of the region, the second stores the height, and the third is reserved. ------------------------------------------------------------------------
but in fact experimenting by writing on disk with BlockWrite the image of a part of a white screen obtained with Size := ImageSize(10, 20, 30, 40); GetMem(P, Size); { Allocate memory on heap } GetImage(10, 20, 30, 40, P^);
the result is Size = 258 and:
00000 14 00 14 00 ¦ FF FF F8 FF ¦ FF F8 FF FF ¦ F8 FF FF F8 00010 FF FF F8 FF ¦ FF F8 FF FF ¦ F8 FF FF F8 ¦ FF FF F8 FF 00020 FF F8 FF FF ¦ F8 FF FF F8 ¦ FF FF F8 FF ¦ FF F8 FF FF 00030 F8 FF FF F8 ¦ FF FF F8 FF ¦ FF F8 FF FF ¦ F8 FF FF F8 00040 FF FF F8 FF ¦ FF F8 FF FF ¦ F8 FF FF F8 ¦ FF FF F8 FF 00050 FF F8 FF FF ¦ F8 FF FF F8 ¦ FF FF F8 FF ¦ FF F8 FF FF 00060 F8 FF FF F8 ¦ FF FF F8 FF ¦ FF F8 FF FF ¦ F8 FF FF F8 00070 FF FF F8 FF ¦ FF F8 FF FF ¦ F8 FF FF F8 ¦ FF FF F8 FF 00080 FF F8 FF FF ¦ F8 FF FF F8 ¦ FF FF F8 FF ¦ FF F8 FF FF 00090 F8 FF FF F8 ¦ FF FF F8 FF ¦ FF F8 FF FF ¦ F8 FF FF F8 000A0 FF FF F8 FF ¦ FF F8 FF FF ¦ F8 FF FF F8 ¦ FF FF F8 FF 000B0 FF F8 FF FF ¦ F8 FF FF F8 ¦ FF FF F8 FF ¦ FF F8 FF FF 000C0 F8 FF FF F8 ¦ FF FF F8 FF ¦ FF F8 FF FF ¦ F8 FF FF F8 000D0 FF FF F8 FF ¦ FF F8 FF FF ¦ F8 FF FF F8 ¦ FF FF F8 FF 000E0 FF F8 FF FF ¦ F8 FF FF F8 ¦ FF FF F8 FF ¦ FF F8 FF FF 000F0 F8 FF FF F8 ¦ FF FF F8 FF ¦ FF F8 FF FF ¦ F8 FF FF F8 00100 00 00
i.e. - width and height are 16 bit integer (as expected for BP) - reserved word is put at the end. Furthermore the arrangement of pixels is rather strange: this is not 3 bytes per pixel as it seems (count the total): each pixel occupies 12 bits (again count).
The same made with grx on djgpp shows a more extensive header with 32 bits words for the width and height parameters, and each three bytes "pixel" word is extended to four bytes (padding a null byte). With some experimentation you could dump an image with gpc/grx and replace inside each block of three bytes by padded four bytes.
Good luck
Maurice