Procedure xDRAWPIC;
{-----------------}
var // bild: THandle;
BM: TBitMap;
Name: String;
x, y, e, nr, mode, tcol: longint;
TempDC, MemDC : HDC;
Data: PChar;
bufsize: longint;
BI: TBitMapInfo;
BIH: TBitMapInfoHeader;
loeschen: boolean;
Begin
e := IOResult;
LesePara(ParStack,',',0);
loeschen := true;
PCol := 0;
if RPar.Typ = 1 then begin
If AnsiUpperCase(ExtractFileExt(RPar.Str)) = '.PNG' Then Begin
Bild := LoadPng(RPar.Str);
End Else If AnsiUpperCase(ExtractFileExt(RPar.Str)) = '.BMP' Then Begin
Bild := LoadBitMapFile(PChar(RPar.Str));
End Else If AnsiUpperCase(ExtractFileExt(RPar.Str)) = '.RLE' Then Begin
Bild := LoadBitMapFile(PChar(RPar.Str));
End Else Begin
Bild := Ole_LoadImage(RPar.Str, PicBackCol);
End;
end else begin
If GetObjectType(LongWord(RPar.Lng)) = OBJ_BITMAP Then Begin
RPar.Str := IntToStr(RPar.Lng);
Bild := RPar.Lng;
loeschen := false;
end else begin // Modul-Handle
Bild := RPar.Lng;
LesePara(ParStack,',',1);
name := RPar.Str;
Val(RPar.Str,nr,E);
If E > 0 Then
Bild := LoadBitmap(Bild,PChar(name))
Else
Bild := LoadBitmap(Bild,MakeIntResource(nr));
end;
end;
If (Bild = 0) or (GetObjectType(LongWord(Bild)) <> OBJ_BITMAP) Then Begin
WarnungNr(228,RPar.Str);
PX := 0;
PY := 0;
BMPBitsPixel := 0;
PCol := 0;
BMPF := 0;
Bild := 0;
end else begin
LesePara(ParStack,',',0);
x := RPar.Lng;
LesePara(ParStack,';',0);
y := RPar.Lng;
If (XPos(',',Par) = 0) Then Begin
LesePara(ParStack,' ',0);
mode := RPar.Lng; // Zeichenmodus
tcol := -1; // keine Transparenzfarbe angegeben
End Else Begin
LesePara(ParStack,' ',0);
mode := RPar.Lng; // Zeichenmodus
LesePara(ParStack,' ',0);
tcol := C2RGB(RPar.Lng); // Transparenzfarbe
end;
{$I-}
GetObject(Bild, sizeOf(BM), @BM);
PX := BM.bmWidth;
PY := BM.bmHeight;
If PCol = 0 Then Begin // <> 0 : BMP
BMPBitsPixel := BM.bmbitspixel;
PCol := 1 shl Max(BM.bmbitspixel,24);
End;
BMPF := 1.0;
If mode = -1 Then Begin {transparent}
If Druck Then FehlerNr(221,'DRAWPIC mit Transparenz');
If Bild = MBild Then Begin
DrawTransDC(DC,MBmpDC,0,0,x,y,PX,PY,tcol);
If DC2 <> DC Then BitBlt(DC2,x,y,PX,PY,DC,x,y,SrcCopy);
End Else Begin
DrawTransBitmap(DC, Bild,x,y,PX,PY,tcol);
If DC2 <> DC Then BitBlt(DC2,x,y,PX,PY,DC,x,y,SrcCopy);
End;
End Else Begin
If Druck Then Begin
MemDC := CreateDC('DISPLAY', Nil, Nil, Nil);
bufsize := px * py * 4; // (4 Bytes pro Pixel)
With BIH do begin
biSize := SizeOf(BIH);
biWidth := PX;
biHeight := PY;
biPlanes := 1;
biBitCount := 24; // BM.bmBitsPixel;
biCompression := BI_RGB;
biClrUsed := 0;
biClrImportant := 0;
biSizeImage := bufsize;
end;
GetMem(Data, bufsize);
BI.bmiHeader := BIH;
GetDIBits(MemDC, Bild, 0, PY, Data, BI, DIB_RGB_COLORS);
StretchDIBits(DC,x*DrAuf, y*DrAuf, PX*DrAuf, PY*DrAuf,
0, 0, PX, PY,
Data, BI, DIB_RGB_Colors, SRCCopy);
FreeMem(Data, bufsize);
DeleteDC(MemDC);
End Else Begin
If Bild = MBild Then Begin
BitBlt(DC, x,y,PX,PY,MBmpDC,0,0,BMode(mode));
BitBlt(DC2,x,y,PX,PY,MBmpDC,0,0,BMode(mode));
End Else Begin
TempDC := CreateDC('DISPLAY', Nil, Nil, Nil);
MemDC := CreateCompatibleDC(TempDC);
OldBild := SelectObject(MemDC,Bild);
BitBlt(DC, x,y,PX,PY,MemDC,0,0,BMode(mode));
If DC2 <> DC Then BitBlt(DC2,x,y,PX,PY,MemDC,0,0,BMode(mode));
Bild := SelectObject(MemDC,OldBild);
DeleteDC(MemDC);
DeleteDC(TempDC);
End;
End;
End;
if loeschen then deleteObject(Bild);
end;
OK := True;
End;
Alles anzeigen