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
 Why does this code fail to load .PSD file?
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

yogiyang

India
730 Posts

Posted - Mar 20 2015 :  23:00:36  Show Profile  Reply
Hello,

I am using following code to load .PSD files in ImageEnView.

MainForm.ImageEnViewMain.LayersClear;
MainForm.ImageEnViewMain.Blank;
MainForm.ImageEnViewMain.MouseInteract := [];
MainForm.ImageEnViewMain.Update;
//============= Load user selected File
if FileExists(fName) then
begin
    MainForm.ImageEnViewMain.IO.Params.PSD_LoadLayers := True;
    MainForm.ImageEnViewMain.IO.LoadFromFilePSD(fName);
    MainForm.ImageEnViewMain.MouseInteract := [miMoveLayers, miResizeLayers];
    MainForm.ImageEnViewMain.Layers[0].Locked := True;
    MainForm.ImageEnViewMain.Update;
end
else
begin
    ShowMessage('Cannot Open "PSD" File');
    exit;
end;


But on executing this code the file is loaded but what we see is a blank ImageEnView. And I have observed that there is an extra layer (0th layer) in the file loaded. So for example if the original .PSD file has 20 layers when loaded in ImageEnView there will be one extra layer added to it. Why?

Currently as a work around what I am doing is loading .PSD file twice! First loading the PSD with the Param - PSD_LoadLayers set to False and then reloading the file again immediately by setting this parameter to True. But this workaround is taking very long time to load the files this is noticeable when a user loads very large (around 150 MB) .PSD files.

Here is the work around code:

MainForm.ImageEnViewMain.IO.Params.PSD_LoadLayers := False;
MainForm.ImageEnViewMain.IO.LoadFromFilePSD(fName);
MainForm.ImageEnViewMain.IO.Params.PSD_LoadLayers := True;
MainForm.ImageEnViewMain.IO.LoadFromFilePSD(fName);


TIA


Yogi Yang

xequte

39086 Posts

Posted - Mar 23 2015 :  13:29:05  Show Profile  Reply
Hi Yogi

Where can we download your example PSD files?



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

yogiyang

India
730 Posts

Posted - Mar 24 2015 :  01:21:09  Show Profile  Reply
Two files are attached here.

These files were saved from ImageEn itself.

TIA


attach/yogiyang/201532411915_YogiTest001.zip
1975.71 KB

attach/yogiyang/201532412038_YogiTest002.zip
2442.77 KB


Yogi Yang
Go to Top of Page

xequte

39086 Posts

Posted - Mar 30 2015 :  02:07:59  Show Profile  Reply
We cannot reproduce this. What version are you using?


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

yogiyang

India
730 Posts

Posted - Mar 30 2015 :  07:02:07  Show Profile  Reply
I am using version 6 of ImageEn in DX6


Yogi Yang
Go to Top of Page

xequte

39086 Posts

Posted - Mar 31 2015 :  11:32:51  Show Profile  Reply
Hi

Can you create a small demo and email it to us.



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

yogiyang

India
730 Posts

Posted - Mar 31 2015 :  23:21:36  Show Profile  Reply
Ok I will do this but please give me some time to messup one.




Yogi Yang
Go to Top of Page

Sybren

34 Posts

Posted - Oct 28 2015 :  17:22:56  Show Profile  Reply
Hi Nigel, Yogi,

I had the same issue with version 6.2.0. I tried Yogi's workaround but that didn't work for me. I use D7 and XE4, both give an EAccessViolation. Here is the code that creates the error. It first reads two files with Button1, then with Button2 it reads the newly created .psd file, replacing the original ImageEnView1 in the Form.

procedure TForm1.Button1Click(Sender: TObject);
begin
  { loads two layer pictures and saves as a 2-layer psd file }
  ImageEnView1.IO.LoadFromFileJpeg('back.jpg');
  ImageEnView1.LayersAdd;
  ImageEnView1.IO.LoadFromFilePNG('transp.png');
  ImageEnView1.Update;
  ImageEnView1.IO.SaveToFilePSD('saved.psd');
end;

procedure TForm1.Button2Click(Sender: TObject);
var
  psd: TImageEnView;
begin
  { creates a new variable to read and store the psd file }
  psd := TImageEnView.Create(nil);
  psd.IO.Params.PSD_LoadLayers := true;
  psd.IO.Params.PSD_ReplaceLayers := true;
  psd.IO.LoadFromFilePSD('saved.psd');  { <<<< this line gives an EAccessViolation error in imageenview line 13388 }
  { then assigns its content to the original picture }
  ImageEnView1.Assign(psd);
  ImageEnView1.Update;
  psd.Free;
end;

I'm kinda stuck here. I can't read multi-layered .psd files, nor individual layers from psd files using a third Button3:

procedure TForm1.Button3Click(Sender: TObject);
var
  psd: TImageEnView;
begin              
  { similar as above, but now only load layer 2 }
  psd := TImageEnView.Create(nil);
  psd.IO.Params.PSD_LoadLayers := true;
  psd.IO.Params.PSD_SelectLayer := 'Layer 2';
  psd.IO.LoadFromFilePSD('saved.psd');
  ImageEnView1.Assign(psd);
  ImageEnView1.Update;
  psd.Free;
end;

Help is much appreciated.

Sybren
Go to Top of Page

xequte

39086 Posts

Posted - Oct 28 2015 :  23:27:37  Show Profile  Reply
Hi Sybren

It works if you use

psd.LegacyBitmap := False;

And LegacyBitmap should always be disabled for new projects.

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

Sybren

34 Posts

Posted - Oct 29 2015 :  02:26:56  Show Profile  Reply
Hi Nigel,

Thanks for the quick answer.
Yes it does work now.

Much appreciated!

Sybren
Go to Top of Page

yogiyang

India
730 Posts

Posted - Nov 02 2015 :  09:43:21  Show Profile  Reply
After updating to the new version of IE the error seems to have gone away except when we encrypt all the layers from bottom to top the error returns when decrypting them. :(




Yogi Yang
Go to Top of Page

xequte

39086 Posts

Posted - Nov 02 2015 :  18:56:00  Show Profile  Reply
Hi Yogi

Please show some example code to reproduce this.



Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: