ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Convert image files on the fly?
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

PeterPanino

933 Posts

Posted - Mar 28 2014 :  10:07:06  Show Profile  Reply
Hi! Is it possible to convert image files like in a Copy action? For example:

ConvertCopyImageFile(source.gif, target.png);

In this case the file source.gif would be copied and converted to target.png. The transparency (if any) would be handled automatically.

Is this possible?

w2m

USA
1990 Posts

Posted - Mar 28 2014 :  10:31:49  Show Profile  Reply
There is a problem with your example.

GIF files can have more than one frame, PNG files can hold only one frame, so if you tried to convert a multiframe gif file to png it is only possible to convert the first frame or convert all frames to individual png file... all with a different filename.

This can be done, but we have to know what you are trying to do?
Convert the first frame, convert a specific frame, or convert all frames?

The way this is coded depends on your needs, given the file formats you are converting from and converting to. I suppose you could design this to convert from one multi-frame format to another multi-frame format like GIF to TIF or GIF to icon or you could design it to only convert one frame to the destination file format regardless of the number of frames in the source file.

William Miller
Adirondack Software & Graphics
Email: w2m@frontiernet.net
EBook: http://www.imageen.com/ebook/
Apprehend: http://www.frontiernet.net/~w2m/index.html
Custom ImageEn Development
Go to Top of Page

xequte

38608 Posts

Posted - Mar 29 2014 :  02:08:30  Show Profile  Reply
Hi Peter

If you are only doing a straight file to file conversion then you can use the IEConvertImageFile function in iexHelperFunctions.pas:

http://www.imageen.com/help/IEConvertImageFile.html

Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page

w2m

USA
1990 Posts

Posted - Mar 29 2014 :  06:14:04  Show Profile  Reply
Nigel,

Doesn't the IEConvertImageFile function only convert single frame files? I believe so... then the best way to convert multi-frame files is to use ImageEnMIO isn't it?

William Miller
Go to Top of Page

PeterPanino

933 Posts

Posted - Mar 30 2014 :  04:46:02  Show Profile  Reply
Hi Nigel,

thanks! This works very well!

I need this in an environment where only single frame images are used. Thanks to all!
Go to Top of Page

PeterPanino

933 Posts

Posted - Mar 30 2014 :  09:07:53  Show Profile  Reply
Unfortunately ConvertCopyImageFile does not work with .JFIF image files.

So is there a way to make ConvertCopyImageFile work with .JFIF image files?
Go to Top of Page

w2m

USA
1990 Posts

Posted - Mar 30 2014 :  10:37:27  Show Profile  Reply
JFIF files are not supported by ImageEn. JIF files are saved as a jpeg file however:
procedure TImageEnIO.SaveToFile(const FileName: WideString; ImageFormat: TIOFileType = -1);
var
  ex: string;
  fpi: TIEFileFormatInfo;
  fs: TIEWideFileStream;
  Progress: TProgressRec;
begin
  ex := string(IEExtractFileExtW(FileName));
  if FileName = '' then
    exit;
  if (ImageFormat = ioJPEG) or (ex = '.jpg') or (ex = '.jpeg') or (ex = '.jpe') or (ex='.jif') then
    SaveToFileJpeg(FileName)

William Miller
Adirondack Software & Graphics
Email: w2m@frontiernet.net
EBook: http://www.imageen.com/ebook/
Apprehend: http://www.frontiernet.net/~w2m/index.html
Custom ImageEn Development
Go to Top of Page

xequte

38608 Posts

Posted - Mar 30 2014 :  13:03:18  Show Profile  Reply
@Bill

Yes, you would need to use a TImageEnMIO to convert a file of multiple frames between formats

Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page

PeterPanino

933 Posts

Posted - Mar 30 2014 :  13:34:41  Show Profile  Reply
It seems I was able to load JFIF with this code:
TPicture.RegisterFileFormat('jfif', 'JFIF Image File', TJPEGImage);
ImageEnIO1.LoadFromFileAuto('MyImage.JFIF');
Go to Top of Page

w2m

USA
1990 Posts

Posted - Mar 30 2014 :  13:53:03  Show Profile  Reply
Yes, but as far as I can tell, when you save it, the file will not be saved because the file type JFIF is not supported by ImageEnIO.SaveToFile as shown in my previous post.

I have no idea how registering the JFIF file format with TPicture will affect saving the file. It may save... or it may not because JFIF is not a supported ImageEnIO file format.

If you can save the file as JFIF and then reload it after the save please let me know, because this is not documented anywhere that I am aware of.

William Miller
Adirondack Software & Graphics
Email: w2m@frontiernet.net
EBook: http://www.imageen.com/ebook/
Apprehend: http://www.frontiernet.net/~w2m/index.html
Custom ImageEn Development
Go to Top of Page

PeterPanino

933 Posts

Posted - Mar 31 2014 :  07:51:32  Show Profile  Reply
My code from above has a strange behavior: If (and only then) a PNG image was previously loaded in the TImage before the JFIF image then the JFIF is not displayed in the TImage under certain conditions.

So I now load the JFIF with this code and it always works well:

TPicture.RegisterFileFormat('jfif', 'JFIF Image File', TJPEGImage);
ThisJPEGImage := TJPEGImage.Create;
try
  ThisJPEGImage.LoadFromFile('MyImage.jfif');
  timageImage.Picture.Bitmap.Assign(ThisJPEGImage);
finally
  ThisJPEGImage.Free;
end;

(Of course RegisterFileFormat should be executed only once at program start)
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: