Nigel,
I uninstalled the ImageEn packages from the IDE and closed the IDE.
I totally deleted all ImageEn files from the components folder.
I extracted the files in the repository zip file to the components folder.
I restarted the IDE and installed the ImageEn packages.
The source was from the repository.
procedure TForm1.AddLayer1Click(Sender: TObject);
var
iRGB: TRGB;
iLayer: Integer;
begin
if Assigned(PageControl1.ActivePage) then
begin
ImageEnView := TImageEnView(PageControl1.ActivePage.Controls[0]);
if Assigned(ImageEnView) then
begin
Screen.Cursor := crHourglass;
try
iLayer := ImageEnView.LayersAdd(ielkImage);
ImageEnView.LayersCurrent := iLayer;
ImageEnView.Layers[iLayer].Name := 'Layer ' +
IntToStr(ImageEnView.LayersCount + 1);
ImageEnView.Layers[iLayer].Selectable := True;
ImageEnView.Layers[iLayer].PosX := 0;
ImageEnView.Layers[iLayer].PosY := 0;
ImageEnView.Layers[iLayer].Width := ImageEnView.IEBitmap.Width;
ImageEnView.Layers[iLayer].Height := ImageEnView.IEBitmap.Height;
iRGB := ImageEnView.IEBitmap.Pixels[0, ImageEnView.IEBitmap.Height - 1];
ImageEnView.Proc.SetTransparentColors(iRGB, iRGB, 0);
ImageEnView.Update;
ImageEnView.IEBitmap.Modified := True;
UpdateGUI;
UpdateFrame;
UpdateLayers;
DrawLayers;
UpdateStatusBar;
EnableControls(LayersTabSheet1, True);
finally
Screen.Cursor := crDefault;
end;
end;
end;
end;
procedure TForm1.DrawRectangle;
{ Draw rectangle. }
var
iIECanvas: TIECanvas;
iPenSize: Integer;
iPenColor: TColor;
iPenAlpha: Integer;
ix1, ix2, iy1, iy2: Integer;
begin
if Assigned(PageControl1.ActivePage) then
begin
ImageEnView := TImageEnView(PageControl1.ActivePage.Controls[0]);
if Assigned(ImageEnView) then
begin
MyUndo(ImageEnView);
{ Draw on the Non-Alpha Canvas }
iIECanvas := TIECanvas.Create(ImageEnView.IEBitmap.Canvas,
Antialias1.Checked, UseGDIPlus1.Checked);
iPenSize := StrToIntDef(PenSize1.Text, 15);
iPenColor := PenColor.Color;
iPenAlpha := IEOpacityToAlpha(StrToIntDef(PenOpacity1.Text, 100));
iIECanvas.Pen.Color := iPenColor;
iIECanvas.Pen.Transparency := iPenAlpha;
iIECanvas.Pen.Style := psSolid;
iIECanvas.Pen.Width := iPenSize;
iIECanvas.Brush.Style := bsClear;
ix1 := AStartX;
iy1 := AStartY;
ix2 := ALastX;
iy2 := ALastY;
{ Adjust the coordinates based on the direction of the drag }
if ix2 <= ix1 then
begin
ix1 := ix1 + iPenSize;
if ix2 = 1 then
ix2 := 0;
end;
if iy2 <= iy1 then
begin
iy1 := iy1 + iPenSize;
if iy2 = 1 then
iy2 := 0;
end;
{ Order the coordinates, putting the first as top-left }
OrdCor(ix1, iy1, ix2, iy2);
iIECanvas.Rectangle(ix1, iy1, ix2, iy2);
iIECanvas.Free();
{ Draw on the Alpha Canvas }
iIECanvas := ImageEnView.IEBitmap.AlphaChannel.CreateROICanvas
(Rect(ix1 - iPenSize, iy1 - iPenSize, ix2 + iPenSize, iy2 + iPenSize),
Antialias1.Checked, UseGDIPlus1.Checked);
iIECanvas.Pen.Width := iPenSize;
iIECanvas.Pen.Style := psSolid;
iIECanvas.Pen.Transparency := iPenAlpha;
iIECanvas.Pen.Color := iPenAlpha or (iPenAlpha shl 8) or
(iPenAlpha shl 16);
iIECanvas.Brush.Style := bsClear;
iIECanvas.Rectangle(ix1, iy1, ix2, iy2);
iIECanvas.Free();
ImageEnView.Update;
UpdateFrame;
ImageEnView.IEBitmap.Modified := True;
ImageEnMView1.IEMBitmap.Modified := True;
end;
end;
end;
procedure TForm1.MergeLayers1Click(Sender: TObject);
var
i: integer;
begin
if Assigned(PageControl1.ActivePage) then
begin
ImageEnView := TImageEnView(PageControl1.ActivePage.Controls[0]);
if Assigned(ImageEnView) then
begin
Screen.Cursor := crHourglass;
try
for i := 1 to ImageEnView.LayersCount - 1 do
ImageEnView.LayersMerge(0, i, True);
UpdateGUI;
UpdateLayers;
UpdateStatusBar;
finally
Screen.Cursor := crDefault
end;
end;
end;
end;
procedure TForm1.ImageEnViewMouseMove(Sender: TObject; Shift: TShiftState;
X, Y: Integer);
var
iX: Integer;
iY: Integer;
iPoint: TPoint;
iAlpha: Integer;
iRGB: TRGB;
iRGBString: string;
iColor: TColor;
iisImageLayer: Boolean;
begin
{ Variables for Backbuffer drawing }
ABX := X;
ABY := Y;
{ Display X, Y and Opacity }
iX := ImageEnView.Layers[ImageEnView.LayersCurrent].ConvXScr2Bmp(X);
iY := ImageEnView.Layers[ImageEnView.LayersCurrent].ConvYScr2Bmp(Y);
iPoint.X := iX;
iPoint.Y := iY;
iisImageLayer := ImageEnView.CurrentLayer is TIEImageLayer;
if (iisImageLayer) and (iX >= 0) and (iX <= ImageEnView.IEBitmap.Width - 1)
and (iY >= 0) and (iY <= ImageEnView.IEBitmap.Height - 1) then
begin
{ Display X, Y position }
LabelX1.Caption := 'Column: ' + IntegerToString(iX + 1);
LabelY1.Caption := 'Row: ' + IntegerToString(iY + 1);
{ Get color and alpha }
if not UseCurrentLayer1.Checked then
iAlpha := ImageEnView.Layers[0].Bitmap.Alpha[iX, iY]
else
iAlpha := ImageEnView.Layers[ImageEnView.LayersCurrent]
.Bitmap.Alpha[iX, iY];
if not UseCurrentLayer1.Checked then
ColorUnderCursor1.Brush.Color :=
TRGB2TColor(ImageEnView.Layers[0].Bitmap.Pixels[iX, iY])
else
ColorUnderCursor1.Brush.Color :=
TRGB2TColor(ImageEnView.Layers[ImageEnView.LayersCurrent]
.Bitmap.Pixels[iX, iY]);
AlphaUnderCursor1.Caption := 'Alpha: ' + IntToStr(iAlpha);
OpacityUnderCursor1.Caption := 'Opacity: ' +
IntToStr(IEAlphaToOpacity(iAlpha)) + '%';
After drawing on the added layer with alpha of 151 the layer was merged.
After merging, the alpha of the drawn rectangle is 255. The dithered color
appears to be correct, but the alpha is always 255. All alpha = 0 pixels are 0. All non 0 alpha pixels are now 255.
I can not see anything wrong and the code has always preformed as expected in the past. I emailed you the full project souce.
Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development