Skip to content

Instantly share code, notes, and snippets.

@ssg
Created September 6, 2024 21:07
Show Gist options
  • Save ssg/aa88f11a8e3d669c7151c42dca61de07 to your computer and use it in GitHub Desktop.
Save ssg/aa88f11a8e3d669c7151c42dca61de07 to your computer and use it in GitHub Desktop.
OS/2 to Windows Bitmap converter I coded back in 1994
uses GDrivers,XIO,Objects,XTypes;
var
I,O:TDosStream;
BC:TBMPCore;
BX:TBMPExtra;
Quad:QuadPal;
RGB:PalType;
BS:TBMPSimple;
s,d:FNameStr;
n:byte;
Buf:Pointer;
BufSize:word;
begin
XAppInit('OS/2 to Windows Bitmap Converter','1.00a','SSG',2,'infile outfile');
write('converting...');
s := XAddExt(ParamStr(1),'.BMP');
d := XAddExt(ParamStr(2),'.BMP');
I.Init(s,stOpenRead);
O.Init(d,stCreate);
I.Read(BS,SizeOf(BS));
if BS.HdrSize > 12 then XAbort('not an OS/2 bitmap');
with BC do begin
HdrSize := 40;
BMId := BS.BMId;
FSize := 0;
DataStart := 0;
SizeX := BS.SizeX;
SizeY := BS.SizeY;
Planes := BS.Planes;
BitCount := BS.BitCount;
DataStart := SizeOf(BC)+SizeOf(BX)+4*16;
end;
O.Write(BC,SizeOf(BC));
FillChar(BX,SizeOf(BX),0);
O.Write(BX,SizeOf(BX));
I.Read(RGB,SizeOf(PalType));
FillChar(Quad,SizeOf(QuadPal),0);
for n:=0 to 15 do Move(RGB[n],Quad[n],SizeOf(TRGB));
O.Write(Quad,4*16);
BufSize := (BS.SizeX+Byte(odd(BS.SizeX)))*BS.SizeY div 2;
GetMem(Buf,BufSize);
I.Seek(74);
I.Read(Buf^,BufSize);
O.Write(Buf^,BufSize);
FreeMem(Buf,BufSize);
BC.FSize := O.GetSize;
O.Seek(0);
O.Write(BC,SizeOf(BC));
I.Done;
O.Done;
ok;
writeln;
writeln('SSG operation complete');
end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment