trichview.com

trichview.support




Re: Auto-Convert Bitmap to JPG-Image


Return to index


Author

Message

Michael Beck

Posted: 08/09/2002 21:15:20


"Sergey Tkachenko" <svt@trichview.com> wrote in message

news:3d53d7ba@support.torry.net...


> I'v posted an example how to convert matafiles imported from RTF to bmp.

> It's not difficult to change it to jpegs (one note: as far as I remember,

in

> the latest version procedure for OnCustomImageItem has one additional

> parameter):


OK, that's how it works for now. If it is metafile, it converst it first to

BMP, and then to JPG.


However, there are two issues:


1) when I want to compress the JPG, it generates (Scan line index out of

range) error

2) if I comment it out, it works, but when I try save or export, it

generates the same error as above.


Any ideas?


Thanks,


Michael


=======================



procedure TForm3.DoOnRTFImage(RVData: TCustomRVData; Graphic: TGraphic;

  Hypertext: Boolean; var item: TCustomRVItemInfo;

  var FreeGraphic: Boolean; RTFPicture: TRVRTFPicture);

var

  bmp: TBitmap;

  jpg: TJPEGImage;

begin

  if Graphic is TMetafile then

    begin

      bmp := TBitmap.Create;

      bmp.Width := Graphic.Width;

      bmp.Height := Graphic.Height;

      bmp.Canvas.Draw(0, 0, Graphic);

      Graphic := bmp;

      FreeGraphic := True;

    end;


  if Graphic is TBitmap then

    begin

      jpg := TJPEGImage.Create;

      jpg.assign(Graphic);

      jpg.CompressionQuality:=75;

//      jpg.Compress;     // <== error (Scan line index out of range)

      Graphic := jpg;

      FreeGraphic := True;

    end;


  if Graphic = nil then

    begin

      bmp := TBitmap.Create;

      bmp.Width := 32;

      bmp.Height := 32;

      bmp.Canvas.Brush.Color := clBtnFace;

      bmp.Canvas.FillRect(Rect(0, 0, 32, 32));

      Graphic := bmp;

    end;

  if Hypertext then

    item := TRVHotGraphicItemInfo.CreateEx(RVData, Graphic, rvvaBaseline)

  else

    item := TRVGraphicItemInfo.CreateEx(RVData, Graphic, rvvaBaseline);

end;






Powered by ABC Amber Outlook Express Converter