[Lazarus] to the BGRABitmap maintainer...

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

[Lazarus] to the BGRABitmap maintainer...

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/


--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] to the BGRABitmap maintainer...

Aleksa Todorovic
On Tue, Apr 19, 2011 at 10:47, Graeme Geldenhuys
<[hidden email]> wrote:

> 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.

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] to the BGRABitmap maintainer...

Graeme Geldenhuys
On 19/04/2011 11:34, 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/


--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] to the BGRABitmap maintainer...

Felipe Monteiro de Carvalho
It would be good if the author puts his name in the wiki page about
this library: http://wiki.lazarus.freepascal.org/BGRABitmap

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.

--
Felipe Monteiro de Carvalho

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] to the BGRABitmap maintainer...

Felipe Monteiro de Carvalho
On Tue, Apr 19, 2011 at 1:04 PM, Felipe Monteiro de Carvalho
<[hidden email]> 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

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus