22 #ifndef PSP_PIXEL_FORMAT_H 23 #define PSP_PIXEL_FORMAT_H 25 #include "graphics/pixelformat.h" 26 #include "backends/platform/psp/trace.h" 52 PSPPixelFormat::Type &bufferType,
53 PSPPixelFormat::Type &paletteType,
55 static Graphics::PixelFormat convertToScummvmPixelFormat(PSPPixelFormat::Type type,
bool fakeAlpha =
false);
57 inline uint32 rgbaToColor(uint32 r, uint32 g, uint32 b, uint32 a)
const {
62 color = (((b >> 4) << 8) | ((g >> 4) << 4) | ((r >> 4) << 0) | ((a >> 4) << 12));
65 color = (((b >> 3) << 10) | ((g >> 3) << 5) | ((r >> 3) << 0) | ((a >> 7) << 15));
68 color = (((b >> 3) << 11) | ((g >> 2) << 5) | ((r >> 3) << 0));
71 color = (((b >> 0) << 16) | ((g >> 0) << 8) | ((r >> 0) << 0) | ((a >> 0) << 24));
80 inline void colorToRgba(uint32 color, uint32 &r, uint32 &g, uint32 &b, uint32 &a)
const {
83 a = (color >> 12) & 0xF;
84 b = (color >> 8) & 0xF;
85 g = (color >> 4) & 0xF;
86 r = (color >> 0) & 0xF;
93 a = (color >> 15) ? 0xFF : 0;
94 b = (color >> 10) & 0x1F;
95 g = (color >> 5) & 0x1F;
96 r = (color >> 0) & 0x1F;
103 b = (color >> 11) & 0x1F;
104 g = (color >> 5) & 0x3F;
105 r = (color >> 0) & 0x1F;
111 a = (color >> 24) & 0xFF;
112 b = (color >> 16) & 0xFF;
113 g = (color >> 8) & 0xFF;
114 r = (color >> 0) & 0xFF;
122 inline uint32 setColorAlpha(uint32 color, byte alpha) {
125 color = (color & 0x0FFF) | (((uint32)alpha >> 4) << 12);
128 color = (color & 0x7FFF) | (((uint32)alpha >> 7) << 15);
131 color = (color & 0x00FFFFFF) | ((uint32)alpha << 24);
140 inline uint32 pixelsToBytes(uint32 pixels)
const {
141 switch (bitsPerPixel) {
154 PSP_ERROR(
"Incorrect bitsPerPixel value[%u]. pixels[%u]\n", bitsPerPixel, pixels);
161 inline uint32 getColorValueAt(byte *pointer)
const {
164 switch (bitsPerPixel) {
170 result = *(uint16 *)pointer;
173 result = *(uint32 *)pointer;
177 PSP_ERROR(
"Incorrect bitsPerPixel value[%u].\n", bitsPerPixel);