Re: Pixel format conversion
- From: Kaba <none@xxxxxxxx>
- Date: Fri, 28 Oct 2005 16:20:41 +0300
> I want to convert one pixel format to another pixel format. For example
> 8bit raw pixel data to 16 bit raw...16 to 24...32 to 16.....etc....
>
> -What's the best way and fast to do this conversion?
I just solved this same problem. If you are into generic programming and
are using C++, you can write a single function to encompass conversions
from any pixel format to other. And in efficient way, probably the same
performance as hand written code. The key is to generate the code at
compile-time.
Have a look at the files in here:
http://kaba.hilvi.org/project/convert/
Unfortunately the code depends on additional header files, which I did
not include. Also it uses some of the Loki librarys meta-programming
templates, such as typelists. However, if you _understand_ how it works,
then you have your own version running up in no time.
The power of generic and meta programming is astonishing here. 73 rows
are sufficient to convert between any integer bit formats (there is also
code for float component conversion, so it extends to 153).
Example of usage:
unsigned int color = 0xFF123124;
unsigned short otherFormatColor = ImageFormatConvert
<ImageFormatIntegerArgb<8,8,8,8>, ImageFormatIntegerArgb<1,5,5,5>
>::leftToRight(color);
--
Kalle Rutanen
http://kaba.hilvi.org
.
- References:
- Pixel format conversion
- From: splender . dev
- Pixel format conversion
- Prev by Date: Re: Pixel format conversion
- Next by Date: Re: Photogrametry algorithms (3D from 2D images)
- Previous by thread: Re: Pixel format conversion
- Next by thread: Photogrametry algorithms (3D from 2D images)
- Index(es):
Relevant Pages
|