Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2011-04

to the BGRABitmap maintainer...

5 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Graeme Geldenhuys

Hi,

I have been taking a quick look at the BGRABitmap package and looked through a few of the tutorials posted on the FPC Wiki. The library seems quite impressive - nice work.

I have found a rather gaping API flaw though, regarding these two methods:

function BGRA(red, green, blue, alpha: byte): TBGRAPixel; overload;
function BGRA(red, green, blue: byte): TBGRAPixel; overload;
From the name, one would expect the parameters to be "blue", "green",

"red", "alpha", but in fact that is not the case - but rather the reverse is true.

Maybe a more sensible name for those methods would be RGBA(...)? That way the name of the method matches the parameters order better.

eg: Code take from: http://wiki.freepascal.org/BGRABitmap

bmp.FillRect(40,40,80,80,BGRA(0,0,255,128), dmDrawWithTransparency);

If one doesn't know the API and parameter names, but rather just looking at the code itself, I would have thought the above code would draw a Red square, not a Blue square.

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/
Aleksa Todorovic
to Graeme Geldenhuys
Graeme Geldenhuys wrote 28 lines
Hi, I have been taking a quick look at the BGRABitmap package and looked through a few of the tutorials posted on the FPC Wiki. The library seems quite impressive - nice work. I have found a rather gaping API flaw though, regarding these two methods: function BGRA(red, green, blue, alpha: byte): TBGRAPixel; overload; function BGRA(red, green, blue: byte): TBGRAPixel; overload; >From the name, one would expect the parameters to be "blue", "green", "red", "alpha", but in fact that is not the case - but rather the reverse is true. Maybe a more sensible name for those methods would be RGBA(...)? That way the name of the method matches the parameters order better. eg: Code take from: ?http://wiki.freepascal.org/BGRABitmap bmp.FillRect(40,40,80,80,BGRA(0,0,255,128), dmDrawWithTransparency); If one doesn't know the API and parameter names, but rather just looking at the code itself, I would have thought the above code would draw a Red square, not a Blue square.

red-green-blue is "standard" order of RGB components, so changing it to blue-green-red wouldn't be very wise. Maybe changing function names to something more suitable is better? I believe this is little annoyance - once you take a look at parameter names, you see what is their meaning.

Graeme Geldenhuys
to Aleksa Todorovic
Aleksa Todorovic wrote
red-green-blue is "standard" order of RGB components, so changing it to blue-green-red wouldn't be very wise. Maybe changing function names to something more suitable is better?

That is exactly the point I'm trying to make. Everybody knows the order as being R-G-B, but the function BGRA() seems to imply B-G-R order.

I think renaming those two functions to RGBA() would be more logical - even if you don't know the parameter names (ie: just by looking at a code sample).

I believe this is little annoyance - once you take a look at parameter names, you see what is their meaning.

Yes, but just looking at a code sample, like the ones in BGRABitmap Tutorial wiki page, is rather confusing. The function name implies a non-standard order.

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/
Felipe Monteiro de Carvalho
to Felipe Monteiro de Carvalho
Felipe Monteiro de Carvalho wrote
It would also be good if the sources are put in subversion in a normal way, instead of putting zip files in subversion with the sources.

Ok, ignore that =D I was looking at the wrong place ...

Felipe Monteiro de Carvalho