When I try to use, an "access violation" exception rise at the line:
RVData.GetRVData.SetPictureInfo(itemno, s, tgraphic(Jpg), VAlign, Tag);
I,m using the richview 15
Code: Select all
///procedure
procedure TForm3.EnumItemsProc(RVData: TCustomRVData; ItemNo: Integer;
var UserData1: Integer; const UserData2: String;
var ContinueEnum: Boolean);
var gr: TGraphic;
jpg: TJPEGImage;
bmp: TBitmap;
Tag: TRVTag;
VAlign: TRVVAlign;
s: TRVAnsiString;
begin
if RVData.GetItem(ItemNo) is TRVGraphicItemInfo then begin
RVData.GetPictureInfo(ItemNo,s,gr,VAlign,Tag);
if (gr is TPngImage) or (gr is TJPEGImage) then exit;
////converter imagem para bmp
bmp := TBitmap.Create;
try
bmp.Assign(gr);
except
bmp.Width := gr.Width;
bmp.Height := gr.Height;
bmp.Canvas.Draw(0, 0, gr);
end;
////converter imagem de bmp para jpeg
try
Jpg := TJPEGImage.Create;
Jpg.Assign(Bmp);
RVData.GetRVData.SetPictureInfo(itemno, s, tgraphic(Jpg), VAlign, Tag);
finally
//PNG.Free;
jpg.Free;
end;
bmp.Free;
end;
ContinueEnum := True;
end;
///call
sRichViewEdit1.RichViewEdit.RVData.EnumItems(EnumItemsProc, v, '');
sRichViewEdit1.RichViewEdit.format;
///register class
initialization
RVGraphicHandler.RegisterJpegGraphic(TJPEGImage);
///units
uses JPEG, PngImage, RVFuncs, CRVData, RVGrHandler....