@
furious programming, thanks by good example about scanline and help for detect platform.
I used something similar, but after
// for each bitmap row
for LineIndex := 0 to ABitmap.Height - 1 do
begin
instead
// get the pointer to the first pixel of the given row
Line := ABitmap.ScanLine[LineIndex];
// for each pixel of the current row
for PixelIndex := 0 to ABitmap.Width - 1 do
begin
// modify the values of the pixel components, using the pointer to the pixels row
Line^[PixelIndex].B := Line^[PixelIndex].B * ADimLevel shr 8;
Line^[PixelIndex].G := Line^[PixelIndex].G * ADimLevel shr 8;
Line^[PixelIndex].R := Line^[PixelIndex].R * ADimLevel shr 8;
end;
I put following cod:
{Here
lScanlineDest : Pointer;
PixelsArray : TArrOfBytes; (array of byte)}
lScanlineDest := bm.scanline[yy];
move(PixelsArray[0], PByte(lScanlineDest^), ABitmap.Width * 3); // Is Working
Using of move is faster, but it is have not a sense here.
The cause is that by using any standard method of Lazarus or Delphi for change pixels we cannot obtain good speed by following problem:
When we change some pixels each standard method begin
make struct of TBitMap. Aproximate 95% of time takes work for change palette.
1. Color of each changed pixel is necessary compare with each color of palette for detect if it is new color or already exists. If changed color is new then standard method
2. add it to palette,
3. increase used memory for new color,
4. assign new number for new color,
5. and this new color fixes to new pixel instead color of this pixel.
It is slowly and coder cannot avoit it.
Does exists two better ways :
1. Make struct of TBitMap and use Bitmap.LoadFromStream.
It is difficult but is fastest.
2. Generate new palette and use SetPalette method. After this
can be change any pixel, but instead color use number of this color from generate palette. It would be much more faster than any standard method, but regrettably I did not find methods for perform this.
@
lucamar and @
howardpc, many thanks by comment. You posts helped me change point of view.