Implemented get_pixel_size_for(). I tested it a bit and it seems correct. I'd be glad if someone reviewed it, though.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13074 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stefano Ceccherini
2005-06-12 07:14:42 +00:00
parent 2c458b6dbf
commit 96b5c85819
+86 -2
View File
@@ -52,8 +52,92 @@ const struct screen_id B_MAIN_SCREEN_ID = {0};
status_t
get_pixel_size_for(color_space space, size_t *pixelChunk, size_t *rowAlignment, size_t *pixelsPerChunk)
{
// TODO: Implement
return B_ERROR;
status_t status = B_OK;
int32 bytesPerPixel = 0;
int32 pixPerChunk = 0;
switch (space) {
// supported
case B_RGB32: case B_RGBA32:
case B_RGB32_BIG: case B_RGBA32_BIG:
case B_UVL32: case B_UVLA32:
case B_LAB32: case B_LABA32:
case B_HSI32: case B_HSIA32:
case B_HSV32: case B_HSVA32:
case B_HLS32: case B_HLSA32:
case B_CMY32: case B_CMYA32: case B_CMYK32:
bytesPerPixel = 4;
pixPerChunk = 1;
break;
case B_RGB24: case B_RGB24_BIG:
case B_UVL24: case B_LAB24: case B_HSI24:
case B_HSV24: case B_HLS24: case B_CMY24:
bytesPerPixel = 3;
pixPerChunk = 1;
break;
case B_RGB16: case B_RGB15: case B_RGBA15:
case B_RGB16_BIG: case B_RGB15_BIG: case B_RGBA15_BIG:
bytesPerPixel = 2;
pixPerChunk = 1;
break;
case B_CMAP8: case B_GRAY8:
bytesPerPixel = 1;
pixPerChunk = 1;
break;
case B_GRAY1:
bytesPerPixel = 1;
pixPerChunk = 8;
break;
case B_YCbCr422: case B_YUV422:
bytesPerPixel = 4;
pixPerChunk = 2;
break;
case B_YCbCr411: case B_YUV411:
bytesPerPixel = 12;
pixPerChunk = 8;
break;
case B_YCbCr444: case B_YUV444:
bytesPerPixel = 3;
pixPerChunk = 1;
break;
// TODO: I don't know if it's correct,
// but beos reports B_YUV420 to be
// 6 bytes per pixel and 4 pixel per chunk
case B_YCbCr420: case B_YUV420:
bytesPerPixel = 3;
pixPerChunk = 2;
break;
case B_YUV9:
bytesPerPixel = 5;
pixPerChunk = 4;
break;
case B_YUV12:
bytesPerPixel = 6;
pixPerChunk = 4;
break;
// unsupported
case B_NO_COLOR_SPACE:
default:
status = B_BAD_VALUE;
break;
}
if (pixelChunk != NULL)
*pixelChunk = bytesPerPixel;
size_t alignment = 0;
if (bytesPerPixel != 0) {
alignment = (sizeof(int) % bytesPerPixel) * sizeof(int);
if (alignment < sizeof(int))
alignment = sizeof(int);
}
if (rowAlignment!= NULL)
*rowAlignment = alignment;
if (pixelsPerChunk!= NULL)
*pixelsPerChunk = pixPerChunk;
return status;
}