-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2026791
commit ed94eb7
Showing
2 changed files
with
23 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
1555ColorPicker.html | ||
ColorConverter/*.exe |
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,22 @@ | ||
#include <stdio.h> | ||
#include <stdint.h> | ||
|
||
int main(void) { | ||
unsigned int color; | ||
unsigned int red; | ||
unsigned int green; | ||
unsigned int blue; | ||
printf("Enter RGB565 value: "); | ||
scanf("%x", &color); | ||
red = ((((color >> 11) & 0x1F) * 527) + 23) >> 6; | ||
green = ((((color >> 5) & 0x3F) * 259) + 33) >> 6; | ||
blue = (((color & 0x1F) * 527) + 23) >> 6; | ||
printf("Red: %d\n", red); | ||
printf("Green: %d\n", green); | ||
printf("Blue: %d\n", blue); | ||
uint32_t rgbHex = red << 16 | green << 8 | blue; | ||
printf("Hex: %x\n", rgbHex); | ||
uint16_t rgb565 = ((red & 0xF8) << 8) | ((green & 0xFC) << 3) | (blue >> 3); | ||
printf("RGB565 value: %x", rgb565); | ||
return 0; | ||
} |