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
 Resizing images
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

JTT

USA
3 Posts

Posted - Mar 19 2021 :  15:56:20  Show Profile  Reply
I have an app that loads an RTF doc into a RichEdit and converts into a 96 DPI BMP for annotating with an ImageENVect using layers.

This worked fine on older lower res tablets. But on newer higher res tablets the BMP appears so small as to be almost unreadable in the ImageENVect.

What can be used to manipulate the image size prior to loading it into the ImagENVect? The current size of the BMP's is 816 W x 1344 H, The desired size is 1280 W x 1656 H.

Also, is there a way to check a tablet's resolution to determine how much the image needs to be resized in order to enforce consistency across different machines?

TIA.


John

JTT

xequte

39053 Posts

Posted - Mar 19 2021 :  17:45:36  Show Profile  Reply
Hi John

If you use a TIERichEdit, then you can easily load an RTF file and output it to an image of any size:

const
  Out_Width   = 500;
  Out_Height  = 800;
  Text_Margin = 20;
var
  re : TIERichEdit;
  bmp: TIEBitmap;
  textRect: TRect;
begin
  bmp := TIEBitmap.Create;
  re := TIERichEdit.CreateParented(HWND(HWND_MESSAGE));
  try
    re.Visible  := False;
    re.WordWrap := False;
    re.OpenFromFile( 'D:\RTF Document.rtf' );

    bmp.width  := Out_Width;
    bmp.height := Out_Height;

    textRect := Rect( Text_Margin,
                      Text_Margin,
                      Out_Width - Text_Margin,
                      Out_Height - Text_Margin );

    re.PaintTo( bmp, textRect, iehCenter, ievCenter, True );

    bmp.Write('D:\RtfImage.jpeg' );
  finally
    bmp.Free;
    re.Free;
  end;
end;


Info: https://www.imageen.com/help/TIERichEdit.PaintTo.html


With regard to tablets, are you looking to get the Screen.Width/Height?

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

JTT

USA
3 Posts

Posted - Mar 21 2021 :  00:15:07  Show Profile  Reply
Nigel,

Wow! I wasn't even aware that IERichEdit existed.

The code sample is extremely helpful. One detail I left out though, the RTFs the app opens can contain multiple pages- a maximum of 5. Are there methods which allow me to determine how many pages the RTF contains and iterate through each page saving each to a separate BMP?

In regard to your question, ideally I'd like to make the app adjust the size of the BMPs according to host screen size.

Thanks once again.

John

JTT
Go to Top of Page

xequte

39053 Posts

Posted - Mar 21 2021 :  00:46:08  Show Profile  Reply
Hi John

I don't think there is a way to paginate documents with RichEdit.

There are a number of methods to get the screen size, it depends on what you are looking for (e.g. when there are multiple monitors). You are better to google "Delphi screen size"

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

JTT

USA
3 Posts

Posted - Mar 21 2021 :  10:48:14  Show Profile  Reply
Nigel,

The current logic determines the number of pages, outputting each page to a separate BMP.
Maybe the simplest approach is to resize each BMP? How do I manipulate the BMP's height and width while maintaining the original aspect ratio?

Thanks again for the help.

John

JTT
Go to Top of Page

xequte

39053 Posts

Posted - Mar 22 2021 :  00:23:36  Show Profile  Reply
Hi John

In my TIERichEdit example you can set the image size to whatever you like. Because the Rich Edit is wrapped the width does not matter much.

After setting the width, call the following to calculate the height:

  // Calc height of text at this width
  textH := Editor.MeasureText( 0, textW ).Y;


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