My favorites | Sign in
Project Home Downloads Wiki Issues Source
READ-ONLY: This project has been archived. For more information see this post.
Search
for
ColorConversion  
Conversion de couleurs
Updated Oct 3, 2008 by samuel.r...@gmail.com

Introduction

BMP file format

Details

16 bits (565) => 32 bits (888)

typedef struct _SPixel565 {
    unsigned char B : 5;
    unsigned char G : 6;
    unsigned char R : 5:
} SPixel 565;

typedef struct _SPixel888 {
    unsigned short B;
    unsigned short G;
    unsigned short R;
} SPixel888;

unsigned int convert (unsigned short src)
{
    SPixel565 tmp = (SPixel565)src;
    SPixel888 dst;

    dst.R = (src.R << 3) + (src.R >> 2);
    dst.G = (src.G << 2) + (src.G >> 4);
    dst.B = (src.B << 3) + (src.B >> 2);

    return dst;
}

16 bits (555) => 32 bits (888)

typedef struct _SPixel555 {
    unsigned char B : 5;
    unsigned char G : 5;
    unsigned char R : 5:
} SPixel 555;

typedef struct _SPixel888 {
    unsigned short B;
    unsigned short G;
    unsigned short R;
} SPixel888;

unsigned int convert (unsigned short src)
{
    SPixel555 tmp = (SPixel555)src;
    SPixel888 dst;

    dst.R = (src.R << 3) + (src.R >> 2);
    dst.G = (src.G << 3) + (src.G >> 2);
    dst.B = (src.B << 3) + (src.B >> 2);

    return dst;
}
Powered by Google Project Hosting