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

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Chromakey saving to jpg

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
bruce seymour Posted - Feb 22 2016 : 15:35:37
Just starting out with you product.

Using your chromakey demo I have successfully created an image with a background and a transparent foreground with jpg files. I now want to save it as a jpg. I have tried variations of

ImageEnView1.LayersMergeAll;
ImageEnView1.IO.SaveToFileJpeg('C:\output.jpg);

and

ImageEnView1.LayersSaveMergedTo('C:\output.jpg);

The images merger and save but the transparency is lost.

How do I preserver transparency and save to a jpg file?


Bruce

5   L A T E S T    R E P L I E S    (Newest First)
xequte Posted - Feb 28 2016 : 21:02:56
Hi

I can see no reason the ShowMessage() would make any difference, though you could try calling ImageEnView1.Update() (as I can't see if your code does that).

Failing that, please email me a very simple demo showing the issue.


Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
bruce seymour Posted - Feb 22 2016 : 17:56:59
below procedures works but notice comment - if I remote showmessage it stops working.

I'm looping through a filelist and applying chromekey to all files in the filelist.



procedure TFormChromaKey.FileListBoxGreenDoneChromeClick(Sender: TObject);
var
    BackGroundFileName, ForeGroundFileName : String;
    Tolerance: Double;
begin
    ForeGroundFileName := FileListBoxGreenDoneChrome.Directory + '\' + FileListBoxGreenDoneChrome.Items[FileListBoxGreenDoneChrome.ItemIndex];
    ImageEnViewForeground.IO.LoadFromFileJpeg(ForeGroundFileName);
    If DM1.dbTableReceivedEmail.FindKey([JustFileNameS(ForeGroundFileName)]) then begin
       BackGroundFileName := cfGSImageFolder + '\'
                            + DM1.dbTableReceivedEmail.FieldByName('PackageCode').AsString + '\'
                            + JustFileNameS(DM1.dbTableReceivedEmail.FieldByName('BackGroundFileName').AsString);
       If FileExists(BackGroundFileName) then begin
          ImageEnViewBackGround.IO.LoadFromFileJpeg(BackGroundFileName);
          ImageEnView1.LayersCurrent := 0;
          ImageEnView1.IO.LoadFromFile(BackGroundFileName);
          ImageEnView1.LayersCurrent := 1;
          fForegroundSrc.Read(ForeGroundFileName);
          if fForegroundSrc.Width > 1024 then fForegroundSrc.Resample( 1024, -1 );
          ImageEnView1.Deselect;
          ImageEnView1.Layers[ 1 ].Bitmap.Assign( fForegroundSrc );
          ImageEnView1.Deselect;
          ImageEnView1.Layers[ 1 ].Bitmap.Assign( fForegroundSrc );
          KeyColor := ImageEnView1.Proc.GuessChromaKeyColor( Tolerance );
          DelayedApplyChromaKey();


  // It works with below showmessage  // i tryed placing pauses in here but didn't work
          Showmessage('xyz');

  // If I remove showmessage it saves but the foreground loses it's transparency

          SaveTransParentLayers('C:\GoodEyeOw\ALL-GREEN\Done\' + JustFileNameS(ForeGroundFileName));
          end;
       end;
end;

// routine you sent
procedure TFormChromaKey.SaveTransParentLayers(SFileName: String);
var
   aBitmap: TIEBitmap;
begin
   aBitmap := TIEBitmap.Create;
   try
    aBitmap.Allocate( ImageEnView1.Width, ImageEnView1.Height );
    ImageEnView1.LayersDrawTo( aBitmap );
    aBitmap.Write(sFileName);
    finally
    FreeAndNil( aBitmap );
    end;
end;

/////////////////////////////////////////////////////
This button DOESN'T WORK

procedure TFormChromaKey.Button2Click(Sender: TObject);
begin
    FileListBoxGreenDoneChromeClick(Sender);  // will 
    SaveTransParentLayers('c:\testimage.jpg');
end;

///////////////////////////////////////////////////
This button WORKS if I run FileListBoxGreenDoneChromeClick(Sender);  first without showmessage;

procedure TFormChromaKey.Button2Click(Sender: TObject);
begin
    SaveTransParentLayers('c:\testimage.jpg');
end;

bruce seymour Posted - Feb 22 2016 : 17:16:46
Chromakey save works great as long as I run it from a button.

If I call your save routine from my routine that does the chromakey build it loses the transparency, same as before. I tried a sleep(4000) and ImageEnView1.Refresh before calling the save but no luck. If I put a showmessage('xyx'); to make it pause before calling the save routine it works.

What command do I use to prepare the ImageEnView1 before calling your save routine?

Bruce
xequte Posted - Feb 22 2016 : 16:31:13
Hi Bruce

JPEG format does not support transparency.

Can you post your before and after images to show us what you mean?

Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
wesleybobato Posted - Feb 22 2016 : 15:39:44
Hi Bruce
Use this method Work OK.

var
 aBitmap: TIEBitmap;
begin
 aBitmap := TIEBitmap.Create;
  try
   aBitmap.Allocate( ImageEnView1.Width, ImageEnView1.Height );
   ImageEnView1.LayersDrawTo( aBitmap );
   aBitmap.Write( sFilename );
  finally
   FreeAndNil( aBitmap );
  end;
end;