Casa
Top.Mail.Ru Yandeks.Metrika
Fórum: "Principal";
Arquivo atual: 2002.01.08;
Download: [xml.tar.bz2];

Para baixo

Problema com o tamanho da imagem ao imprimir Encontre agências semelhantes


Oleg Gashev   (2001-12-15 11:14) [0]

Никак не получается распечать Image с точными размерами. Он все равно распечатывается неправильно.
Делаю я так. Нахожу размеры Bitmapa в inch:

sx,sy:real;
ABitmap:=Image1.Picture.Bitmap;
sx:=ABitmap.Width/GetDeviceCaps(image1.canvas.handle,LOGPIXELSX);
sy:=ABitmap.Height/GetDeviceCaps(image1.canvas.handle,LOGPIXELSY);


Теперь нахожу размеры в пикселах на принтере для распечатки:

relwidth:=trunc(GetDeviceCaps(Printer.canvas.handle,LOGPIXELSX)*sx);
relheight:=trunc(GetDeviceCaps(Printer.canvas.handle,LOGPIXELSY)*sy);


Печать:

Printer.BeginDoc;
DrawImage(Printer.Canvas, Rect(0, 0, relWidth, relHeight), ABitmap);
Printer.EndDoc;


DrawImage:

procedure DrawImage(Canvas: TCanvas; DestRect: TRect; ABitmap: TBitmap);
var Header, Bits: Pointer;
HeaderSize: Cardinal;
BitsSize: Cardinal;
begin
GetDIBSizes(ABitmap.Handle, HeaderSize, BitsSize);
Header := AllocMem(HeaderSize);
Bits := AllocMem(BitsSize);
try
GetDIB(ABitmap.Handle, ABitmap.Palette, Header^, Bits^);
StretchDIBits(Canvas.Handle, DestRect.Left, DestRect.Top, DestRect.Right, DestRect.Bottom, 0, 0, ABitmap.Width, ABitmap.Height, Bits,TBitmapInfo(Header^), DIB_RGB_COLORS, SRCCOPY);
finally
FreeMem(Header, HeaderSize);
FreeMem(Bits, BitsSize);
end;
end;


Все это печатает с неверными размерами. Где же ошибка?

С уважением, Олег.



MrBeer   (2001-12-16 21:27) [1]

//Print bitmap X x Y millimeters size
procedure PrintBM(B:TBitmap;x_mm,y_mm:double);
var resx,resy:double;
begin
resx:=Printer.PageWidth/GetDeviceCaps(Printer.Handle,LOGPIXELSX);
resy:=Printer.PageHeight/GetDeviceCaps(Printer.Handle,LOGPIXELSY);
Printer.Canvas.StretchDraw(Rect(0,0,round(x_mm*resx),round(y_mm*resy)),B);
end;
//Print bitmap X x Y inch size
procedure PrintBMInch(B:TBitmap;x_inch,y_inch:double);
begin
PrintBM(B,x_inch*2.54,y_inch*2.54);
end;



MrBeer   (2001-12-16 21:40) [2]

procedure PrintSameSize(B:TBitmap);
var scalex,scaley:double;
begin
scalex:=GetDeviceCaps(Printer.Handle,LOGPIXELSX)/GetDeviceCaps(B.Canvas.Handle,LOGPIXELSX);
scaley:=GetDeviceCaps(Printer.Handle,LOGPIXELSY)/GetDeviceCaps(B.Canvas.Handle,LOGPIXELSY);
Printer.Canvas.StretchDraw(Rect(0,0,round(B.Width*scalex),round(B.Height*scaley)),B);
end;



MrBeer   (2001-12-16 21:48) [3]

A esli tak napisatj ?
// ....
scalex:=GetDeviceCaps(Printer.Handle,LOGPIXELSX)/GetDeviceCaps(GetDC(0),LOGPIXELSX);
scaley:=GetDeviceCaps(Printer.Handle,LOGPIXELSY)/GetDeviceCaps(GetDC(0),LOGPIXELSY);



Страницы: 1 filial inteira

Fórum: "Principal";
Arquivo atual: 2002.01.08;
Download: [xml.tar.bz2];

em cima









Memória: 0.82 MB
Hora: 0.028 c
3-21898
Delírio
2001-11-30 18:56
2002.01.08
É possível executar de forma assíncrona o procedimento armazenado?


7-22437
Paradoxo
2001-09-25 18:48
2002.01.08
wav


6-22313
SB
2001-10-01 15:05
2002.01.08
Ajude a abandonar a rede! Por favor faça


6-22295
Maamed
2001-10-10 09:15
2002.01.08
Importar de Excell


3-21965
Sarja
2001-12-05 06:13
2002.01.08
Indexação FoxPro





afrikaans albanês Arabic armênio azerbaijano basco belarusian Bulgarian catalão Chinês simplificado) Chinês tradicional) croata checo dinamarquês Dutch Inglês estoniano filipino Finnish French
Galego georgiano German grego crioulo haitiano hebraico hindi húngaro islandês Indonesian irlandês Italian Japanese Korean letão lituano macedónio Malay maltês Norwegian
persa polonês Portuguese romeno Russa sérvio Slovak esloveno espanhol swahili sueco tailandês turco ucraniano urdu vietnamita galês ídiche bengali bósnio
cebuano esperanto gujarati hausa hmong igbo javanês kannada khmer lao latino maori marata mongol Nepali punjabi somali tâmil telugu yoruba
zulu
Английский francês Alemão Italiano Португальский russo Espanhol