Commit 112d87a4 authored by mse1's avatar mse1

* Fixed postscript printinf of timagelist.

git-svn-id: https://mseide-msegui.svn.sourceforge.net/svnroot/mseide-msegui/trunk@937 56ecf5fe-6917-0410-8ac6-ca8e178bccbf
parent 185b748a
......@@ -1480,7 +1480,7 @@ function gui_pixmaptoimage(pixmap: pixmapty; out image: imagety;
gchandle: cardinal): gdierrorty;
var
info: pixmapinfoty;
ximage: pximage;
ximage1: pximage;
po1: pcardinal;
po2: pbyte;
int1,int2: integer;
......@@ -1493,13 +1493,13 @@ begin
image.pixels:= nil;
if info.depth = 1 then begin //monochrome
image.monochrome:= true;
ximage:= xgetimage(appdisp,pixmap,0,0,info.size.cx,info.size.cy,1,xypixmap);
if ximage = nil then begin
ximage1:= xgetimage(appdisp,pixmap,0,0,info.size.cx,info.size.cy,1,xypixmap);
if ximage1 = nil then begin
result:= gde_image;
exit;
end;
{$ifdef FPC} {$checkpointer off} {$endif}
with ximage^ do begin
with ximage1^ do begin
wordmax:= (image.size.cx + 31) div 32;
image.length:= wordmax * image.size.cy;
image.pixels:= gui_allocimagemem(image.length);
......@@ -1542,8 +1542,8 @@ begin
else begin
image.monochrome:= false;
image.length:= image.size.cx * image.size.cy;
ximage:= xgetimage(appdisp,pixmap,0,0,info.size.cx,info.size.cy,$ffffffff,zpixmap);
if ximage = nil then begin
ximage1:= xgetimage(appdisp,pixmap,0,0,info.size.cx,info.size.cy,$ffffffff,zpixmap);
if ximage1 = nil then begin
result:= gde_image;
exit;
end;
......@@ -1555,13 +1555,13 @@ begin
for int1:= 0 to info.size.cy - 1 do begin
for int2:= 0 to info.size.cx - 1 do begin
{$ifdef FPC} {$checkpointer off} {$endif}
po1^:= gui_pixeltorgb(ximage^.f.get_pixel(ximage,int2,int1));
po1^:= gui_pixeltorgb(ximage1^.f.get_pixel(ximage1,int2,int1));
{$ifdef FPC} {$checkpointer default} {$endif}
inc(po1);
end;
end;
end;
xdestroyimage(ximage);
xdestroyimage(ximage1);
end;
end;
......@@ -3948,6 +3948,8 @@ begin
ax:= x;
ay:= y;
end;
fillchar(sattributes,sizeof(sattributes),0);
fillchar(dattributes,sizeof(dattributes),0);
if (cardinal(transparency) <> 0) and not colormask then begin
maskpic:= createmaskpicture(rgbtriplety(cardinal(transparency) xor $ffffff));
pictop:= pictopover;
......
......@@ -16,7 +16,10 @@ type
bitnumty = 0..32;
const
twoexp32 = 4294967296.0;
bytebits: array[0..8] of byte = ($01,$02,$04,$08,$10,$20,$40,$80,$00);
bytemask: array[0..8] of byte = ($00,$01,$03,$07,$0f,$1f,$3f,$7f,$ff);
bytebitsreverse: array[0..8] of byte = ($80,$40,$20,$10,$08,$04,$02,$01,$00);
bits: array[bitnumty] of longword = (
$00000001,$00000002,$00000004,$00000008,
$00000010,$00000020,$00000040,$00000080,
......
......@@ -1409,33 +1409,120 @@ procedure convertmono(const sourcerect: rectty; const image: imagety;
out data: bytearty; out rowbytes: integer);
var
sourcerowstep: integer;
rowshiftleft,rowshiftright: integer;
rowshiftleft,rowshiftright: byte;
po1,po2: pbyte;
int1,int2: integer;
begin
with sourcerect do begin
rowbytes:= (cx + 7) div 8;
setlength(data,rowbytes*cy);
rowshiftleft:= x and $7;
rowshiftright:= 8-rowshiftleft;
rowshiftright:= x and $7;
rowshiftleft:= 8-rowshiftright;
sourcerowstep:= ((image.size.cx + 31) div 32)*4;
po1:= @pbyteaty(image.pixels)^[y * sourcerowstep + x div 8];
sourcerowstep:= sourcerowstep - rowbytes + 1;
sourcerowstep:= sourcerowstep - rowbytes;
po2:= pointer(data);
for int1:= cy - 1 downto 0 do begin
for int2:= rowbytes - 2 downto 0 do begin
po2^:= (po1^ shl rowshiftleft);
for int2:= rowbytes - 1 downto 0 do begin
po2^:= (po1^ shr rowshiftright);
inc(po1);
po2^:= bitreverse[po2^ or (po1^ shr rowshiftright)];
po2^:= bitreverse[po2^ or byte(po1^ shl rowshiftleft)];
//byte(... needed for FPC!
inc(po2);
end;
po2^:= bitreverse[po1^ shl rowshiftleft];
inc(po2);
inc(po1,sourcerowstep);
end;
end;
end;
procedure convertmonotogray(const sourcerect: rectty; var image: imagety;
out data: bytearty; out rowbytes: integer;
const colorforeground,colorbackground: colorty);
var
grf,grb: byte;
po1: pbyte;
po2: pbyte;
int1,int2: integer;
ar1: bytearty;
rowb: integer;
by1: byte;
begin
convertmono(sourcerect,image,ar1,rowb);
image.monochrome:= false;
with colortorgb(colorforeground) do begin
grf:= (red + green + blue) div 3;
end;
with colortorgb(colorbackground) do begin
grb:= (red + green + blue) div 3;
end;
with sourcerect do begin
rowbytes:= cx;
setlength(data,rowbytes*cy);
po2:= pointer(data);
for int1:= 0 to cy - 1 do begin
po1:= @ar1[int1*rowb];
for int2:= 0 to cx - 1 do begin
by1:= bytebitsreverse[int2 and $7];
if po1^ and by1 = 0 then begin
po2^:= grb;
end
else begin
po2^:= grf;
end;
inc(po2);
if by1 = $01 then begin
inc(po1);
end;
end;
end;
end;
end;
procedure convertmonotorgb(const sourcerect: rectty; var image: imagety;
out data: bytearty; out rowbytes: integer;
const colorforeground,colorbackground: colorty);
var
rgbf,rgbb: rgbtriplety;
po1: pbyte;
po2: pbyte;
int1,int2: integer;
ar1: bytearty;
rowb: integer;
by1: byte;
po3: prgbtriplety;
begin
convertmono(sourcerect,image,ar1,rowb);
image.monochrome:= false;
rgbf:= colortorgb(colorforeground);
rgbb:= colortorgb(colorbackground);
with sourcerect do begin
rowbytes:= cx*3;
setlength(data,rowbytes*cy);
po2:= pointer(data);
for int1:= 0 to cy - 1 do begin
po1:= @ar1[int1*rowb];
for int2:= 0 to cx - 1 do begin
by1:= bytebitsreverse[int2 and $7];
if po1^ and by1 = 0 then begin
po3:= @rgbb;
end
else begin
po3:= @rgbf;
end;
po2^:= po3^.red;
inc(po2);
po2^:= po3^.green;
inc(po2);
po2^:= po3^.blue;
inc(po2);
if by1 = $01 then begin
inc(po1);
end;
end;
end;
end;
end;
function tpostscriptcanvas.createpattern(const sourcerect,destrect: rectty;
const acolorbackground,acolorforeground: colorty;
const pixmap: pixmapty; const agchandle: cardinal;
......@@ -1472,7 +1559,7 @@ begin
result:= false;
exit;
end;
str1:= '/'+patname+' '+inttostr(rowbytes*image.size.cy)+' string def'+nl+
str1:= '/'+patname+' '+inttostr(rowbytes*sourcerect.cy)+' string def'+nl+
'currentfile '+patname+' readhexstring'+nl;
streamwrite(str1);
writebinhex(ar1);
......@@ -1574,7 +1661,7 @@ begin
checkcolorspace;
masked:= (mask <> nil) and mask.monochrome;
if masked then begin
if fpslevel >= psl_3 then begin
if (fpslevel >= psl_3) then begin
with source^ do begin
gdi_lock;
if gui_pixmaptoimage(tsimplebitmap1(mask).handle,image,
......@@ -1591,7 +1678,15 @@ begin
gdi_unlock;
end;
if image.monochrome then begin
convertmono(sourcerect^,image,ar3,rowbytes);
// convertmono(sourcerect^,image,ar3,rowbytes);
if colorspace = cos_gray then begin
convertmonotogray(sourcerect^,image,ar3,rowbytes,
fdrawinfo.acolorforeground,fdrawinfo.acolorbackground);
end
else begin
convertmonotorgb(sourcerect^,image,ar3,rowbytes,
fdrawinfo.acolorforeground,fdrawinfo.acolorbackground);
end
end
else begin
if colorspace = cos_gray then begin
......@@ -1606,7 +1701,7 @@ begin
po1:= pointer(ar1);
po2:= pointer(ar2);
po3:= pointer(ar3);
for int1:= image.size.cy - 1 downto 0 do begin
for int1:= sourcerect^.cy - 1 downto 0 do begin
system.move(po2^,po1^,maskrowbytes);
inc(po1,maskrowbytes);
inc(po2,maskrowbytes);
......@@ -1629,7 +1724,7 @@ begin
str1:= str1 + ' >> def'+nl+
'<< /ImageType 3 /DataDict imdict /MaskDict madict /InterleaveType 2 >>'+nl;
if image.monochrome then begin
str1:= str1 + 'imagemask';
str1:= str1 + 'imagemask'; //does not work?
end
else begin
str1:= str1 + 'image';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment