Vampyre Imaging Library Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

Imaging 0.26.4 Released!

Author Topic: Saving from a TImage...  (Read 715 times)

shamballa

  • Imaging User
  • *
  • Offline Offline
  • Posts: 3
    • View Profile
Saving from a TImage...
« on: 5 June 2009, 04:50:13 »

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
Logged

shamballa

  • Imaging User
  • *
  • Offline Offline
  • Posts: 3
    • View Profile
Re: Saving from a TImage...
« Reply #1 on: 5 June 2009, 14:09:18 »

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

Code: [Select]
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

Code: [Select]
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
Logged

Galfar

  • Administrator
  • Imaging User
  • *****
  • Offline Offline
  • Posts: 249
    • ICQ Messenger - 327174200
    • View Profile
    • Galfar's Homepage
    • Email
Re: Saving from a TImage...
« Reply #2 on: 10 June 2009, 23:55:48 »

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:
Code: [Select]
uses ...., ImagingComponents;
begin
  FImage := TSingleImage.Create;
  ConvertBitmapToImage(ASCIIImg.Picture.Bitmap, FImage);
  ....
  FImage.SaveToFile(CopyPath);
  ...
end;

Logged

shamballa

  • Imaging User
  • *
  • Offline Offline
  • Posts: 3
    • View Profile
Re: Saving from a TImage...
« Reply #3 on: 11 June 2009, 18:20:55 »

Hi,

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

shamballa
Logged
 

Page created in 0.071 seconds with 20 queries.