Note: You must be registered in order to post a reply. To register, click here. Registration is FREE!
T O P I C R E V I E W
stkwon
Posted - Nov 12 2018 : 01:40:58 using .IEN files.
i want read layer's property before load..
example.
if using LoadfromfileIEN
then check Text layer's font name
and install fonts before load IEN file.
how can i get layer's information before loadfromIEN?
7 L A T E S T R E P L I E S (Newest First)
xequte
Posted - Feb 06 2019 : 22:47:55 Hi Wesley
After loading an ImageEn layer file you can iterate through all of the fonts to ensure they are valid, for example:
ImageEnView1.IO.LoadFromFileIEN(...);
// Validate fonts are installed on this system
for i := 0 to ImageEnView1.LayersCount do
begin
if ImageEnView1.Layers[i].Kind = ielkText then
fontName := TIETextLayer( ImageEnView1.Layers[i] ).Font
else
if ImageEnView1.Layers[i].Kind = ielkLine then
fontName := TIELineLayer( ImageEnView1.Layers[i] ).LabelFont
else
continue;
if Screen.Fonts.IndexOf( fontName ) = -1 then
begin
// This font is not installed. Substitute or install it...
end;
end;
This task is very complex in my opinion because if it is designed incorrectly will cause slowness as it can cause overload.
// Example 1 Img.ReadParams(FileName.iev); OnBeforeLoadLayer(Img.Params, var AAbort: Boolean);
if not AAbort then ImgReadImage(FileName.iev);
-------------------------------------------------
// Example 2 var pr: TIOParams; pr := TIOParams.Create(nil); pr.ReadParams(FileName.iev);
OnBeforeLoadLayer(pr, var AAbort: Boolean); if not AAbort then begin img.AssignParams(pr); img.ReadImage(FileName.iev); end;
pr.Free;
------------------------------------------------- // Example 3 Img.StartReading(FileName.iev); OnBeforeLoadLayer(Img.Params, var AAbort: Boolean);
if not AAbort then Img.ContinueReadFile;
These are simple examples but you can see that example number 3 does less reading on the storage unit (HD/SSD/SD and etc).
I added the parameter AAbort because I believe that if you can not install the font the programmer may want to cancel the operation.
Kind regards.
xequte
Posted - Nov 15 2018 : 18:01:34 Hi
The problem here is that the user needs to know the name of the font before it is assigned to the layer. So an OnBeforeLoadLayer event would need to list all of the properties that have been loaded, and then after the event they would need to be assigned to the layer (a two stage loading process).
The correct way is to add the OnBeforeLoadImage or OnAfterLoadParams events.
yogiyang
Posted - Nov 13 2018 : 01:49:00 Hello,
In the mean time you can load the file using following code:
var
ieTemp: TImageEnView;
begin
ieTemp := TImageEnView.Create(Application);
ieTemp.IO.Params.JPEG_EnableAdjustOrientation := True;
ieTemp.IO.Params.PSD_LoadLayers := True;
ieTemp.IO.Params.PSD_ReplaceLayers := True;
ieTemp.IO.LoadFromFileIEN('YourFile');
//Loop through each Layer and do the needful here
//Once completed
FreeAndNil(ieTemp);
end;
HTH
Yogi Yang
xequte
Posted - Nov 12 2018 : 17:32:06 Hi
I'm afraid there is not a way to access that information before loading. I will add it to the to-do list.