Le 19/11/2011 21:43, T.D. Telford a écrit :
Hello,
The patch worked fine on the demo programs, and on the chess program that I am converting.
A question on a different subject: The chess program reads the chess piece images by using GetImage, where the images were created under turbo pascal. I get a segment violation when I try to read these images on gpc/grx. I suspect that the header information for the image created by turbo pascal is not compatible with the grx image header information.
Do you know how these turbo pascal images could be read?
No. I have only the sources of the BP RTL, but apparently they do not contain sources of the BGI system. May be somebody reading this list ?
Maurice
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(...)
Best regards, Hartmut
-----Ursprüngliche Nachricht----- From: Maurice Lombardi Sent: Saturday, November 19, 2011 11:01 PM To: T.D. Telford ; grx Subject: Re: GRX, gpc version 20060325, based on gcc-3.4.4 demo programs forproblem
Le 19/11/2011 21:43, T.D. Telford a écrit :
Hello,
The patch worked fine on the demo programs, and on the chess program that I am converting.
A question on a different subject: The chess program reads the chess piece images by using GetImage, where the images were created under turbo pascal. I get a segment violation when I try to read these images on gpc/grx. I suspect that the header information for the image created by turbo pascal is not compatible with the grx image header information.
Do you know how these turbo pascal images could be read?
No. I have only the sources of the BP RTL, but apparently they do not contain sources of the BGI system. May be somebody reading this list ?
Maurice
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
Le 20/11/2011 15:50, Maurice Lombardi a écrit :
Le 20/11/2011 09:39, Hartmut Schirmer a écrit :
Oops, in addition bits are organized in a different order. Please experiment by changing colors with the following program (augmented from the demo program GetImage.pas of BP) It runs identically in BP and in gpc/grx under djgpp ---------------------------------------------------------------------------- {Getimage.PAS} program test; {Sample code for the GetImage procedure.}
uses Graph;
var Gd, Gm: Integer; P: ^Byte; Size: Word; f: File; begin Gd := Detect; InitGraph(Gd, Gm, 'C:\BP\BGI'); if GraphResult <> grOk then begin Writeln('Graphics error'); Readln; Halt(1); end; SetFillStyle(SolidFill,Green); Bar(0, 0, GetMaxX, GetMaxY); Size := ImageSize(10, 20, 30, 40); GetMem(P, Size); { Allocate memory on heap } GetImage(10, 20, 30, 40, P^); assign(f,'IMAGE.GRE'); Rewrite(f,1); BlockWrite(f,P^,Size); Close(f); Writeln(Size); Readln; ClearDevice; PutImage(100, 100, P^, NormalPut); Readln; CloseGraph; end. --------------------------------------------------------------------------
Good luck
Maurice
Maurice Lombardi wrote:
Oops, in addition bits are organized in a different order. Please experiment by changing colors with the following program
It's probably read directly from the graphics memory, google "VGA memory planes". It's rather ugly to handle, and the format was probably never meant for permanent storage (rather than copy/paste or save/restore within an application), leave alone portable storage (<rant>as if Borland ever knew what portable means</rant> ;-).
Regards, Frank