• Welcome to Vampyre Imaging Library Forum. Please login or sign up.
 

Saving from a TImage...

Started by shamballa, 5 June 2009, 04:50:13

Previous topic - Next topic

shamballa

Hi,

This may be a stupid question but is it possible to use a normal TImage with this library?

Basically what I am doing is converting Extended ASCII characters to a Bitmap which I then want to save in other formats but I am a little confused as to how I can do this with a normal TImage Component using this library or if this is even possible?

Please could you inform me if it is?

Many thanks

Shamballa

shamballa

ok I think I have found a way but not sure if it is the best way!

var
  ImgStream: TMemoryStream;
begin
  try
    ImgStream := TMemoryStream.Create;
    FImage := TMultiImage.Create;
    ASCIIImg.Picture.Graphic.SaveToStream(ImgStream);
    ImgStream.Position := 0;
    FImage.LoadMultiFromStream(ImgStream);
  finally
    ImgStream.Free;
  end;


...Then I am saving this way like in the Demo

var
  CopyPath: string;
begin
  SaveDlg.Filter := Imaging.GetImageFileFormatsFilter(False);
  SaveDlg.FileName := ChangeFileExt(ExtractFileName(FFileName), '');
  SaveDlg.FilterIndex := Imaging.GetFileNameFilterIndex(FFileName, False);
  if SaveDlg.Execute then
  begin
    CopyPath := ChangeFileExt(SaveDlg.FileName, '.' +
      Imaging.GetFilterIndexExtension(SaveDlg.FilterIndex, False));
    FImage.SaveToFile(CopyPath);
  end;


* This code "is" saving the images, but is there a better way?

Many thanks

Shamballa

Galfar

Sorry for late answer, so if I understand this correctly:

You have TImage on form with TBitmap assigned to Picture property and you want to save this TBitmap to image file format selected by user.

You can convert TBitmap to Imaging's image easier than in your code this way:

uses ...., ImagingComponents;
begin
  FImage := TSingleImage.Create;
  ConvertBitmapToImage(ASCIIImg.Picture.Bitmap, FImage);
  ....
  FImage.SaveToFile(CopyPath);
  ...
end;



shamballa

Hi,

Thank you very much, it works very well and is shorter code!

shamballa

Quick Reply

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Name:
Email:

Shortcuts: ALT+S save/post or ALT+P preview

SMF spam blocked by CleanTalk