Get the pixel colors and alpha values:
procedure TFormMain.ImageEnViewMouseMove(Sender: TObject; Shift: TShiftState; X, Y: integer);
begin
iBX := ImageEnView.XScr2Bmp(X);
iBY := ImageEnView.YScr2Bmp(Y);
// Show current color and alpha values
CurrentPenColor1.Color := ImageEnView.IEBitmap.Canvas.Pixels[iBX, iBY]
CurrentBrushColor1.Color := ImageEnView.IEBitmap.AlphaChannel.Canvas.Pixels[iBX, iBY];
LabelAlpha1.Caption := 'Alpha: ' + IntToStr(ImageEnView.IEBitmap.Alpha[iBX, iBY]);
end;
Set the pixel colors and alpha values:
procedure TFormMain.ImageEnViewMouseMove(Sender: TObject; Shift: TShiftState; X, Y: integer);
begin
iBX := ImageEnView.XScr2Bmp(X);
iBY := ImageEnView.YScr2Bmp(Y);
iPenTransparency := PenAlpha1.EditValue;
iBrushTransparency := BrushAlpha1.EditValue;
if (DrawButton.Down) and ImageEnView.MouseCapture then
// Paint color and alpha
begin
ImageEnView.Proc.SaveUndoCaptioned('PaintPen ' + IntToStr(ImageEnView.Proc.UndoCount + 1));
Undo1.Hint := 'Paint Pen ' + IntToStr(ImageEnView.Proc.UndoCount + 1);
iPoint.X := ImageEnView.XScr2Bmp(X);
iPoint.Y := ImageEnView.YScr2Bmp(Y);
ImageEnView.HighlightedPixel := iPoint;
ImageEnView.IEBitmap.Canvas.Pixels[iBX, iBY] := dxPenColorGallery1.ColorValue;
ImageEnView.IEBitmap.AlphaChannel.Canvas.Pen.Color := $02000000 or (iPenTransparency) or (iPenTransparency shl 8)
or (iPenTransparency shl 16);
ImageEnView.IEBitmap.AlphaChannel.Canvas.Brush.Color := $02000000 or (iBrushTransparency) or (iBrushTransparency shl 8) or (iBrushTransparency shl 16);
ImageEnView.IEBitmap.AlphaChannel.Canvas.Pixels[iBX, iBY] := dxPenColorGallery1.ColorValue;
ImageEnView.IEBitmap.Alpha[iBX, iBY] := iBrushTransparency;
ImageEnView.Bitmap.Modified := True;
ImageEnView.Update;
end;
end;
TIP: Look the the source code in the simple GDIPLus demo that shipped with my EBook.... or in the ImageEnViewDrawBackBuffer demo shipped with my EBook or my Icon editor in samples.
William Miller
Adirondack Software & Graphics
Email: w2m@frontiernet.net
EBook: http://www.imageen.com/ebook/
Apprehend: http://www.frontiernet.net/~w2m/index.html