forked from cyxx/f2bgl
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move color conversion to textureconvert
- Loading branch information
Showing
7 changed files
with
54 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
|
||
#include "textureconvert.h" | ||
|
||
uint32_t yuv420_to_rgba(int Y, int U, int V) { | ||
float R = Y + 1.402 * (V - 128); | ||
if (R < 0) { | ||
R = 0; | ||
} else if (R > 255) { | ||
R = 255; | ||
} | ||
float G = Y - 0.344 * (U - 128) - 0.714 * (V - 128); | ||
if (G < 0) { | ||
G = 0; | ||
} else if (G > 255) { | ||
G = 255; | ||
} | ||
float B = Y + 1.772 * (U - 128); | ||
if (B < 0) { | ||
B = 0; | ||
} else if (B > 255) { | ||
B = 255; | ||
} | ||
return 0xFF000000 | (((uint8_t)B) << 16) | (((uint8_t)G) << 8) | ((uint8_t)R); | ||
} | ||
|
||
uint32_t bgr555_to_rgba(uint16_t color) { | ||
const uint8_t r = ( color & 31) << 3; | ||
const uint8_t g = ((color >> 5) & 31) << 3; | ||
const uint8_t b = ((color >> 10) & 31) << 3; | ||
return 0xFF000000 | (b << 16) | (g << 8) | r; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
|
||
#ifndef TEXTURECONVERT_H__ | ||
#define TEXTURECONVERT_H__ | ||
|
||
#include "util.h" | ||
|
||
uint32_t yuv420_to_rgba(int Y, int U, int V); | ||
uint32_t bgr555_to_rgba(uint16_t color); | ||
|
||
#endif // TEXTURECONVERT_H__ |