Hello,
Getting the message "Invalid vertical pixel index 1" for the code bellow (I got the idea from here: http://wiki.lazarus.freepascal.org/Fast_direct_pixel_access).
Also, what is the purpose of '* $010101'? >>
TempIntfImage.Colors[X, Y] := TColorToFPColor(FastBitmap.FPixelmap[X, Y]); // * $010101);?
The code does not compile if im using the multiplier.
Thank you.
Purpose of * $010101 was to convert grayscale color format which was originally defined as TFastBitmapPixel = Byte to TColor. I updated wiki page to use abstract function FastPixelToTColor to be more clear that fast bitmap color format needs to be converted to TColor which is used by TCanvas.
In fact this was mentioned in wiki page "In this test let assume that we have simple bitmap structure designed as two dimensional byte array where each pixel have 256 possible colors. This could be gray image or some palette mapped image." just before list of possible drawing methods.
Order of processing X and Y was update in the article so Y is used in outer loop and X is used in inner loop.
Also added some hints to methods
http://wiki.lazarus.freepascal.org/Fast_direct_pixel_access#Draw_methodsAnd the article assume drawing to TImage component instance where Bitmap should already initialized to given size and the drawing doesn't to be done during OnPaint event like in case of drawing directly to Form or PaintBox Canvas. But yes for drawing directly to form canvas it is better to draw to temporary bitmap and then draw to form canvas.
Which reminds me that if you want draw to entire form area then you probably want to redefine main form method:
procedure EraseBackground(DC: HDC); override;
to do nothing:
procedure TFormMain.EraseBackground(DC: HDC);
begin
// Do nothing, all background space covered by controls
end;
And also for Linux you may want set form as opaque using ControlStyle := ControlStyle + [csOpaque];