Hello,
I am using following code to Load images in TImageEnVect on different layers and then merging them all and saving the image as JPG. Here is the code:
// Create a New Doc
ImageEnVect.Blank;
ImageEnVect.ClearAll;
ImageEnVect.Proc.Clear;
ImageEnVect.RemoveAllObjects;
ievMain.Proc.ImageResize(2400, 1200, iehLeft, ievTop);
ImageEnVect.Proc.Fill(clWhite);
ImageEnVect.IO.Params.Dpi := 100;
ImageEnVect.ChangeResolution(100, rfBicubic);
ImageEnVect.Layers[0].Locked := True;
ImageEnVect.Layers[0].Selectable := False;
ImageEnVect.Update;
//Code to Load Images on Layers
FileName := 'F001.jpg';
//Load image in a Temp instance
ieTemp := TImageEnView.Create(Application);
ieTemp.IO.Params.JPEG_EnableAdjustOrientation := True;
ieTemp.LayersAdd;
ieTemp.IO.LoadFromFile('001.jpg');
ieTemp.Proc.Resample(-1, 800, TResampleFilter(4))
LayerCurr := ImageEnVect.LayersAdd;
ImageEnVect.Layers[LayerCurr].Assign(ieTemp.CurrentLayer);
ImageEnVect.Layers[LayerCurr].PosX := 0;
ImageEnVect.Layers[LayerCurr].PosY := 0;
ImageEnVect.Layers[LayerCurr].Name := '001.jpg';
//Add Mask Layer
ImageEnVect.LayersAdd;
ImageEnVect.CurrentLayer.Assign(ievMain.Layers[LayerCurr]);
ImageEnVect.CurrentLayer.Bitmap.PixelFormat := ie8g;
ImageEnVect.Proc.Fill(clwhite);
ImageEnVect.CurrentLayer.Width := 550;
ImageEnVect.CurrentLayer.Height := 800;
ImageEnVect.CurrentLayer.Visible := True;
ImageEnVect.CurrentLayer.IsMask := True;
ImageEnVect.CurrentLayer.Visible := False;
//Load Another File
ieTemp.IO.LoadFromFile('002.jpg');
ieTemp.Proc.Resample(-1, 800, TResampleFilter(4))
LayerCurr := ImageEnVect.LayersAdd;
ImageEnVect.Layers[LayerCurr].Assign(ieTemp.CurrentLayer);
ImageEnVect.Layers[LayerCurr].PosX := 600;
ImageEnVect.Layers[LayerCurr].PosY := 20;
ImageEnVect.Layers[LayerCurr].Name := '002.jpg';
//Add Mask Layer
ImageEnVect.LayersAdd;
ImageEnVect.CurrentLayer.Assign(ievMain.Layers[LayerCurr]);
ImageEnVect.CurrentLayer.Bitmap.PixelFormat := ie8g;
ImageEnVect.Proc.Fill(clwhite);
ImageEnVect.CurrentLayer.Width := 550;
ImageEnVect.CurrentLayer.Height := 800;
ImageEnVect.CurrentLayer.Visible := True;
ImageEnVect.CurrentLayer.IsMask := True;
ImageEnVect.CurrentLayer.Visible := False;
ieTemp.Free;
//Save File using SaveAll
ImageEnVect.SaveToFileAll('MyFileSample.iev', ioPNG);
//Create a JPG thumbnail for viewing in Win Explorer
ImageEnVect.LayersCurrent := 0;
ImageEnVect.Proc.AutoUndo := False;
ImageEnVect.Proc.SaveUndo();
ImageEnVect.LayersMergeAll();
ImageEnVect.Proc.Resample(300, -1, TResampleFilter(rfBSpline));
ImageEnVect.IO.SaveToFileJpeg('MyFileSample.jpg');
ImageEnVect.Proc.Undo(False); //Does not seem to work I don't know as why
ImageEnVect.Proc.AutoUndo := True;
The code is straight forward but the jpg is getting saved as grayscale.
Why?
TIA
Yogi Yang