Recent

Author Topic: Drawing on Canvas is faster than drawing on BGRABitmap  (Read 5168 times)

plashenkov

  • New Member
  • *
  • Posts: 24
Drawing on Canvas is faster than drawing on BGRABitmap
« on: February 14, 2013, 03:32:31 pm »
Hello!

I'm trying to draw semitransparent image (256 x 256 pixels) on BGRABitmap. And I need to draw it as fast as possible.
I noticed that drawing it on BGRABitmap which I use as internal buffer is critically slower than drawing it directly on Canvas.

Hereby the question: why it is so and is there any way to speed up drawing semitransparent image on canvas?

Here is the image I used:
http://johndyer.name/lab/colorpicker/refresh_web/colorpicker/images/map-hue.png

And the second question: after drawing this image on Canvas, I see slightly visible jaggies.
But when drawing on BGRABitmap, I can see smooth and very fine picture.
Why one image is drawn differently?

Thank you!

circular

  • Hero Member
  • *****
  • Posts: 4220
    • Personal webpage
Re: Drawing on Canvas is faster than drawing on BGRABitmap
« Reply #1 on: February 14, 2013, 05:58:15 pm »
To draw faster, try using dmLinearBlend instead of dmDrawWithTransparency.

What do you mean by jaggies ? Do you have a screenshot ?
Conscience is the debugger of the mind

plashenkov

  • New Member
  • *
  • Posts: 24
Re: Drawing on Canvas is faster than drawing on BGRABitmap
« Reply #2 on: February 15, 2013, 11:41:47 am »
Yes, screenshot is attached.

Pictures look almost identical, but if to look very carefully, the jaggies on the left side are visible (usual Canvas-base drawing).

Sure, I use dmLinearBlend for the second picture. It is smooth, but much slower. And I do not know what to do --- I need to repaint picture when changing color in color bar (not presented on screenshot) on mouse move, and it noticeably slows down.

Probably, I can accept the first variant with almost visible jaggies (speed is good in this case), but I do not know how to print the picture with custom master alpha (I will need this too).

Or maybe I do something wrong and there is a way to speed up normal drawing with BGRABitmap?

Thank you very much for your attention to this issue!
Sincerely,
Yury
« Last Edit: February 15, 2013, 11:46:21 am by Yurik »

plashenkov

  • New Member
  • *
  • Posts: 24
Re: Drawing on Canvas is faster than drawing on BGRABitmap
« Reply #3 on: February 15, 2013, 01:16:22 pm »
I tried to use CanvasOpacity --- I supposed this propery controls the common master alpha when drawing on Canvas --- but I see no changes in drawing when changing this parameter.

circular

  • Hero Member
  • *****
  • Posts: 4220
    • Personal webpage
Re: Drawing on Canvas is faster than drawing on BGRABitmap
« Reply #4 on: February 15, 2013, 10:41:31 pm »
Oh it's to draw a color gradient. Well, there are other ways to do that.

- with HSLAToBGRA function to draw each pixel with a PBGRAPixel defined for each ScanLine.
- with FillPolyLinearColor function

CanvasOpacity is only to use LCL functions to draw on the Canvas property, but to define the alpha component (otherwise it is 0 so transparent).
Conscience is the debugger of the mind

plashenkov

  • New Member
  • *
  • Posts: 24
Re: Drawing on Canvas is faster than drawing on BGRABitmap
« Reply #5 on: February 16, 2013, 04:25:00 pm »
Dear circular,

Thank you for your help!

 

TinyPortal © 2005-2018