ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder
ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Header and Footer in print
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

AndNit

Brazil
11 Posts

Posted - Sep 14 2020 :  15:36:52  Show Profile  Reply
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

5500 Posts

Posted - Sep 14 2020 :  17:35:19  Show Profile  Reply
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
Go to Top of Page

AndNit

Brazil
11 Posts

Posted - Sep 14 2020 :  18:11:20  Show Profile  Reply
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?

Go to Top of Page

xequte

5500 Posts

Posted - Sep 15 2020 :  03:16:10  Show Profile  Reply
Sorry, that is a parameter from the upcoming 9.1.2. You can just remove the BG_Color part.

To get the bitmap from TImageEnMView:

https://www.imageen.com/help/TImageEnMView.GetTIEBitmap.html



Nigel
Xequte Software
www.imageen.com
Go to Top of Page

AndNit

Brazil
11 Posts

Posted - Sep 15 2020 :  10:55:54  Show Profile  Reply
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.
Go to Top of Page

xequte

5500 Posts

Posted - Sep 15 2020 :  17:27:13  Show Profile  Reply
Hi

Please attach your output image.

To prevent the black background use Fill:

https://www.imageen.com/help/TIEBitmap.Fill.html

Nigel
Xequte Software
www.imageen.com
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To: