Re: image data
- From: pjb@xxxxxxxxxxxxxxxxx (Pascal J. Bourguignon)
- Date: Fri, 12 Sep 2008 08:59:03 +0200
"mike7411@xxxxxxxxx" <mike7411@xxxxxxxxx> writes:
Anyone know the fastest way to convert 24 bpp BGR image data to 24 bpp
RGB image data in C/C++?
Depends on how these types are declared.
If you have
typedef int RGB;
typedef int BGR;
then:
BGR bgr;
RGB rgb;
rgb=(bgr&0xff00)|(bgr>>16)|((bgr<<16)&&0xff0000);
On the other hand, if you have:
typedef struct { unsigned char r,g,b } RGB;
typedef struct { unsigned char b,g,r } RGB;
then:
BGR bgr;
RGB rgb;
bgr.r=rgb.r;
bgr.g=rgb.g;
bgr.b=rgb.b;
But if you have:
typedef unsigned char RGB[3];
typedef unsigned char BGR[3];
then:
BGR bgr;
RGB rgb;
bgr[0]=rgb[2];
bgr[1]=rgb[1];
bgr[2]=rgb[0];
etc...
--
__Pascal Bourguignon__ http://www.informatimago.com/
Until real software engineering is developed, the next best practice
is to develop with a dynamic system that has extreme late binding in
all aspects. The first system to really do this in an important way
is Lisp. -- Alan Kay
.
- References:
- image data
- From: mike7411@xxxxxxxxx
- image data
- Prev by Date: image data
- Next by Date: Re: parser
- Previous by thread: image data
- Next by thread: Re: image data
- Index(es):
Relevant Pages
|