Access violation with PNG inside table.

General TRichView support forum. Please post your questions here
Post Reply
Marsianin
Posts: 193
Joined: Sun Sep 25, 2005 11:03 pm

Access violation with PNG inside table.

Post by Marsianin »

Delphi 2010, RVE 12.0.4, 5x5 table, TPNGObject (from PNGComponents adapted to D2010).
Inserting PNG picture into the table cell then pressing center alignment button raises Access Violation in RVERVData.pas here:

Code: Select all

function TRVEditRVData.GetCurItemNo: Integer;
  {........................................}
  function IndexOf(obj: TCustomRVItemInfo): Integer;
  var ItemNo: Integer;
  begin
    Result := -1;
    if (CaretDrawItemNo>=0) and (CaretDrawItemNo<DrawItems.Count) then begin
      ItemNo := DrawItems[CaretDrawItemNo].ItemNo;         <<<-----<<<-----[HERE]-----
      if (ItemNo>=0) and (ItemNo<Items.Count) and (GetItem(ItemNo)=obj) then
        Result := ItemNo;
    end;
    if Result<0 then
      Result := Items.IndexOfObject(obj);
  end;
  {........................................}
begin
  PrepareForEdit;
...
Marsianin
Posts: 193
Joined: Sun Sep 25, 2005 11:03 pm

Post by Marsianin »

It seems TPNGObject is a problem.
Moved to internal Delphi 2010 TPNGImage and it seems everything works fine here.

But now I have another problem. Previously I inserted PNG images from TPNGImageList into RVE with this code:

Code: Select all

procedure TMainForm.PicturesPaletteCellClick(Sender: TObject; ACol, ARow: Integer; var Allow: Boolean);
var png:TPNGObject;
begin
  png:=TPNGObject.Create;
  png.Assign(DM.ImageList2.PngImages.Items[ARow*PicturesPalette.RowCount+ACol].PngImage);
  RichViewEdit1.InsertPicture('',png,rvvaAbsBottom);
  Allow:=False;
end;
But now it's doesn't works because TImageList has only GetBitmap and GetIcon routines. But I want to insert PNG.
Is there a solution? Also I'm looking how can I save PNG image from TImageList to file on disk.
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

What happens if you get image from image list as an icon, and then assign TIcon to png?
Marsianin
Posts: 193
Joined: Sun Sep 25, 2005 11:03 pm

Post by Marsianin »

I cannot assign TIcon to TPNGImage.
This will not work:
PNGImage.Assign(TIcon)

but this will:
PNGImage.Assign(TBitmap)

But using bitmap loses transparency :(

Found a code inside PNGComponents on how to convert ICO to PNG...it's a big procedure. Should be easier for D2009/2010
Post Reply