Author |
Topic |
|
AndNit
Brazil
61 Posts |
Posted - Sep 14 2020 : 15:36:52
|
Good afternoon
I would like some help.
I need to print a Multpage TIF file and add a header and footer image. Heading ONLY on the first page and Footing ONLY on the last page,
I need the original images to be resized to fit the header and footer images
Thank you |
|
xequte
38182 Posts |
Posted - Sep 14 2020 : 17:35:19
|
Hi
You are probably best to construct a "Print Bitmap". i.e. draw your header and other image onto the bitmap, and then print that.
Here is some example code:
// Draw two images onto a bitmap above
// Image 1 is centered within the top 30% of the bitmap. Image 2 is centered within the bottom 70% of the bitmap
const
// Size to draw image 1
Image_1_Max_Width = 900;
Image_1_Max_Height = 300; // 30% of output image height
// Size to draw image 2
Image_2_Max_Width = Image_1_Max_Width;
Image_2_Max_Height = 700; // 70% of output image height
// Size of output image
Image_Out_Width = Image_1_Max_Width;
Image_Out_Height = Image_1_Max_Height + Image_2_Max_Height;
BG_Color = clWhite;
var
bmpOut, bmp1, bmp2 : TIEBitmap;
rct1, rct2: TRect;
begin
bmp1 := TIEBitmap.Create();
bmp2 := TIEBitmap.Create();
bmpOut := TIEBitmap.Create( Image_Out_Width, Image_Out_Height, BG_Color );
try
bmp1.Read( 'D:\im.jpg' );
bmp2.Read( 'D:\IMG_20200906_190157.jpg' );
// Draw bmp1 at top of image within allowed space (while maintaing AR)
rct1 := GetImageRectWithinArea( bmp1.Width, bmp1.Height,
Image_1_Max_Width, Image_1_Max_Height );
bmp1.StretchRectTo( bmpOut,
rct1.Left, rct1.Top, RectWidth( rct1 ), RectHeight( rct1 ),
0, 0, bmp1.Width, bmp1.Height,
rfLanczos3 );
// Draw bmp2 below bmp1 within allowed space (while maintaing AR)
rct2 := GetImageRectWithinArea( bmp2.Width, bmp2.Height,
Image_2_Max_Width, Image_2_Max_Height );
bmp2.StretchRectTo( bmpOut,
rct2.Left, Image_1_Max_Height + rct2.Top, RectWidth( rct2 ), RectHeight( rct2 ),
0, 0, bmp2.Width, bmp2.Height,
rfLanczos3 );
// Show in our TImageEnView
ImageEnView1.Assign( bmpOut );
finally
bmp1 .Free;
bmp2 .Free;
bmpOut.Free;
end;
end;
Nigel Xequte Software www.imageen.com
|
|
|
AndNit
Brazil
61 Posts |
Posted - Sep 14 2020 : 18:11:20
|
hello, thank you very much for the answer, but here an error appears.
in this line:
bmpOut := TIEBitmap.Create( Image_Out_Width, Image_Out_Height, BG_Color );
The error is as follows:
[dcc32 Error] uConsCert.pas(2368): E2250 There is no overloaded version of 'Create' that can be called with these arguments
Another doubt, I saw that you loaded the two images from a directory, however, in my case, the first image is inside a TimageEnMView, How to update and have it printed?
|
|
|
xequte
38182 Posts |
|
AndNit
Brazil
61 Posts |
Posted - Sep 15 2020 : 10:55:54
|
Hello good day I managed to get through the error, however in the lines:
rct1.Left, rct1.Top, RectWidth (rct1), RectHeight (rct1)
and
rct2.Left, Image_1_Max_Height + rct2.Top, RectWidth (rct2), RectHeight (rct2),
The following error appears when compiling:
[dcc32 Error] uConsCert.pas (2377): E2003 Undeclared identifier: 'RectWidth' [dcc32 Error] uConsCert.pas (2377): E2003 Undeclared identifier: 'RectHeight'
I changed the content of these lines to:
rct1.Left, rct1.Top, rct1.Width, rct1.Height,
and
rct2.Left, Image_1_Max_Height + rct2.Top, rct2.Width, rct2.Height,
I was able to compile normally, but the result is not as expected (attached). The background is black and the distribution of images is very bad. Would you help me? Thank you.
I also take the opportunity to send as we would like the image to look. |
|
|
xequte
38182 Posts |
|
|
Topic |
|
|
|