Recent

Author Topic: BGRABitmap.Canvas.Rectangle slow  (Read 808 times)

ghamm

  • New Member
  • *
  • Posts: 29
BGRABitmap.Canvas.Rectangle slow
« on: March 28, 2020, 06:43:35 am »
Ive been able to create my pixelator just fine because of your help. It runs perfect. But if I have a large array of colors, want to build a canvas of many shapes, a sort of grid, checker board or sorts.. each element has a color.. Its a fake LED board or sorts.

so, I loop through my array, and put my shapes on my canvas one by one. Works great, but slow if I have to loop for a couple thousand elements.. Just wondering if there is faster way than looping and calling

      TheBitMap.Canvas.Brush.Style := bsClear;
      TheBitMap.Canvas.Brush.Color := LEDArray[FrameNumber, x].Color;
      TheBitMap.Canvas.Pen.Color   := LEDArray[FrameNumber, x].Color;

      if Shape = 0 then
        TheBitMap.Canvas.Ellipse(Rect)
      else
        TheBitMap.Canvas.Rectangle(Rect);
      }                               


Using BGRA doesnt seem to be any faster than the standard TBitmap.. Is there something I could use thats better?




circular

  • Hero Member
  • *****
  • Posts: 4195
    • Personal webpage
Re: BGRABitmap.Canvas.Rectangle slow
« Reply #1 on: April 01, 2020, 11:35:17 am »
I suppose you can work with a smaller image where one pixel is one grid element. You can access it with GetPixel / SetPixel or by using the ScanLine property.

Then you can stretch the image to make it bigger.
Conscience is the debugger of the mind

 

TinyPortal © 2005-2018