Recent

Author Topic: Inserting, Saving and Loading Images  (Read 20951 times)

rick2691

  • Sr. Member
  • ****
  • Posts: 375
Re: Inserting, Saving and Loading Images
« Reply #45 on: September 21, 2016, 06:22:44 pm »
I was able to implement the BitmapToRTF code. Images insert and resize. The RTF file saves and opens with the image intact and editable. Another editor was able to load and edit the file as well.

I wouldn't have been able to do it without your refusal to do so. It made me track everything down. Thanks.

Rick
Windows 10, LAZ 1.6.4, FPC 3.0.2, SVN 54278, i386-win32-win32/win64, forms use windows unit

rick2691

  • Sr. Member
  • ****
  • Posts: 375
Re: Inserting, Saving and Loading Images
« Reply #46 on: September 21, 2016, 06:31:21 pm »
In reference to another snippet of code that you introduced on this thread. The following implementation to resize an image by code performs the work. But after do so, there isn't any problem until I close program. Then it raises an exception...

external: SIGSEGV at address 4B4112E4

It does it every time I close the program after having tested the code. It never does if I haven't tested the code.

Code: Pascal  [Select][+][-]
  1. procedure TCmdForm.MnuResizeClick(Sender: TObject);
  2. var
  3.   ole: IRichEditOle;
  4.   sz: TSize;
  5. begin
  6.   ole:= GetRichEditOLE(PageMemo);
  7.   GetOleObjectSize(ole, PageMemo.SelStart, sz);
  8.   sz.cx:=round(sz.cx * 1.5);  // magnify
  9.   sz.cy:=round(sz.cy * 1.5);
  10.   SetOleObjectSize(ole, PageMemo.SelStart, sz);
  11. end;
  12.  

It happens as a result of calling SetOleObjectSize(ole, PageMemo.SelStart, sz);

Rick
« Last Edit: September 21, 2016, 06:37:25 pm by rick2691 »
Windows 10, LAZ 1.6.4, FPC 3.0.2, SVN 54278, i386-win32-win32/win64, forms use windows unit

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2515
    • havefunsoft.com
Re: Inserting, Saving and Loading Images
« Reply #47 on: September 21, 2016, 06:41:59 pm »
Are images inline images or rtf generated images?

If inline, try to change the code to rtf generated and see if it solves the problem
Patron Cocoa Widgetset development https://www.patreon.com/skalogryz

rick2691

  • Sr. Member
  • ****
  • Posts: 375
Re: Inserting, Saving and Loading Images
« Reply #48 on: September 21, 2016, 07:13:43 pm »
It has always been doing this. I didn't want to bring up until the other issues were settled. I think they had been inline, but I am not using inline. I don't know about RTF files that have images. I'll have to test.

Attached is the assembler message. I scrolled it down a little so you could see what lead into the break. The green arrow is pointing at the break.



Windows 10, LAZ 1.6.4, FPC 3.0.2, SVN 54278, i386-win32-win32/win64, forms use windows unit

rick2691

  • Sr. Member
  • ****
  • Posts: 375
Re: Inserting, Saving and Loading Images
« Reply #49 on: September 21, 2016, 07:27:41 pm »
I loaded a file where another editor had inserted the image. It does the same crash.

It did it with Inline before, and with my separate insert now. It is across the board.

Here is a better image of the crash info. The crash point is near the bottom.

Windows 10, LAZ 1.6.4, FPC 3.0.2, SVN 54278, i386-win32-win32/win64, forms use windows unit

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2515
    • havefunsoft.com
Re: Inserting, Saving and Loading Images
« Reply #50 on: September 21, 2016, 08:02:08 pm »
r5196 should fix the issue. However, the interface of SetOleObjectSize / GetOleObjectSize functions changed. Now the first parameter must be TRichMemo object rather than an IRichMemoOle object.
Patron Cocoa Widgetset development https://www.patreon.com/skalogryz

rick2691

  • Sr. Member
  • ****
  • Posts: 375
Re: Inserting, Saving and Loading Images
« Reply #51 on: September 21, 2016, 08:40:54 pm »
That fixed it. Thank you much.

Code: Pascal  [Select][+][-]
  1. {
  2.  r5196 should fix the issue. However, the interface of SetOleObjectSize / GetOleObjectSize
  3.  functions changed. Now the first parameter must be TRichMemo object rather than an
  4.  IRichMemoOle object.
  5. }
  6. procedure TCmdForm.MnuResizeClick(Sender: TObject);
  7. var
  8.   //ole: IRichEditOle;
  9.   sz: TSize;
  10. begin
  11.   //ole:= GetRichEditOLE(PageMemo);
  12.   GetOleObjectSize(PageMemo, PageMemo.SelStart, sz);
  13.   sz.cx:=round(sz.cx * 1.25);  // magnify
  14.   sz.cy:=round(sz.cy * 1.25);
  15.   SetOleObjectSize(Pagememo, PageMemo.SelStart, sz);
  16. end;
  17.  

The above is the implementation. I can go on with refining the code.

Rick
Windows 10, LAZ 1.6.4, FPC 3.0.2, SVN 54278, i386-win32-win32/win64, forms use windows unit

 

TinyPortal © 2005-2018