Permalink
Browse files

updated reference images, changed ppm to use maxval

  • Loading branch information...
coolaj86 committed Oct 28, 2010
1 parent 0ab465b commit 0777e28c71dffeac21eb73865bdf515bcb819ce6
Showing with 75 additions and 11 deletions.
  1. +1 −0 .gitignore
  2. +7 −4 Makefile
  3. +58 −2 README.md
  4. +9 −5 src/rgb565toppm.c
  5. BIN test/reference.24.bmp.gz
  6. BIN test/reference.32.bmp.gz
View
@@ -1 +1,2 @@
bin
+test/*.bmp
View
@@ -1,15 +1,18 @@
CC_OPTS = -Wall -Werror
-CC += $(CC_OPTS)
+CCS += $(CC_OPTS)
-all: bin/rgb565tobmp bin/rgb565toppm
+all: bin/rgb565tobmp bin/rgb565toppm bin/bmptorgb565
clean: rm bin/ -rf
bin/rgb565tobmp: src/rgb565tobmp.c bin
- @$(CC) -o bin/rgb565tobmp -lbmp src/rgb565tobmp.c >/dev/null 2>/dev/null || \
+ @$(CCS) -o bin/rgb565tobmp -lbmp src/rgb565tobmp.c >/dev/null 2>/dev/null || \
echo ""; echo "#### rgb565tobmp requires libbmp from code.google.com. Skipping... ####"; echo ""
bin/rgb565toppm: src/rgb565toppm.c bin
- @$(CC) -o bin/rgb565toppm src/rgb565toppm.c && echo "Built rgb565toppm."
+ @$(CCS) -o bin/rgb565toppm src/rgb565toppm.c && echo "Built rgb565toppm."
+
+bin/bmptorgb565: src/bmptorgb565.c bin
+ @$(CC) -o bin/bmptorgb565 src/bmptorgb565.c && echo "Built bmptorgb565."
bin:
@mkdir bin
View
@@ -7,13 +7,69 @@ Simple examples of how to convert raw rgb565 frames into other formats.
* BMP (32-bit)
* PPM (P3 Plain)
+Usage
+----
+
+raw rgb565 to ppm:
+
+ # rgb565toppm <infile> <width> <height> <maxval> fb.ppm
+ # rgb565 has maxval of 255 per pixel because it is converted to rgb888
+ rgb565toppm fb.rgb565.bin 720 480 255 fb.ppm
+
+raw rgb565 to bmp:
+
+ # rgb565toppm <infile> <width> <height> <bitdepth> fb.ppm
+ # Bug: only reliably works converting from a depth of 16 to 32
+ rgb565tobmp fb.rgb565.bin 720 480 32 fb.bmp
+
+
Dependecies
====
* [libbmp](http://code.google.com/p/libbmp/)
-TODO
+Bugs
====
- * Upload example rgb565 and reference image
+`bmptorgb565` does not work at all
+----
+
+Header of reference.24.bmp:
+
+ 0000000 42 4d 36 d2 0f 00 00 00 00 00 36 00 00 00 28 00
+ 0000010 00 00 d0 02 00 00 20 fe ff ff 01 00 18 00 00 00
+ 0000020 00 00 00 00 00 00 13 0b 00 00 13 0b 00 00 00 00
+ 0000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+
+Header read:
+
+ type: 4d42
+ total size: 15
+ offset: 2621440
+ width: 4263510016
+ width: 131071
+ bitcount(color depth): 0
+ size image (image size): 185794560
+ image size in bytes: 181440
+
+ Red16: 0
+ Green16: 0
+ Blue16: 0
+ RGB2Bytes: 0
+ Segmentation fault <-- Obvious sign that it doesn't work
+
+
+References
+====
+
+[RGB565 To PNG/JPEG](http://www.swview.org/node/165):
+
+ # Single RAW Image
+ ffmpeg -vcodec rawvideo -f rawvideo -pix_fmt rgb565 -s 1024x768 -i image.raw -f image2 -vcodec png image.png
+
+ # Multiple Images / RAW Video
+ ffmpeg -vcodec rawvideo -f rawvideo -pix_fmt rgb565 -s 1024x768 -i movie.raw -f image2 -vcodec png image%d.png
+
+ # Stream / RAW Video
+ command-that-streams-to-stdout | ffmpeg -vcodec rawvideo -f rawvideo -pix_fmt rgb565 -s 1024x768 -i - -f image2 -vcodec png image%d.png
View
@@ -16,12 +16,14 @@ int main(int argc, char* argv[]) {
unsigned short pixel; // 16-bits per pixel
unsigned int maxval; // max color val
unsigned short width, height;
- int depth;
+ //int depth; // TODO use depth rather than maxval?
size_t i;
// Parse Args
if (argc < 6) {
- printf("Usage: %s infile width height depth outfile.\n", argv[0]);
+ printf("Usage: %s infile width height max-val-per-pixel outfile.\n", argv[0]);
+ printf("EX: %s fb.rgb565.bin 720 480 255 fb.ppm.\n", argv[0]);
+ //printf("Usage: %s infile width height depth outfile.\n", argv[0]);
exit(EXIT_FAILURE);
}
@@ -30,11 +32,12 @@ int main(int argc, char* argv[]) {
width = atoi(argv[2]);
height = atoi(argv[3]);
- depth = atoi(argv[4]);
- maxval = pow(2, depth) - 1;
+ maxval = atoi(argv[4]);
+ //depth = atoi(argv[4]);
+ //maxval = pow(2, ceil(depth/3.0)) - 1;
if (maxval <= 0 || maxval >= 65536) {
- printf("Err: depth must be between 1 and 65535");
+ printf("Err: depth must be between 1 and 65536");
exit(EXIT_FAILURE);
}
@@ -53,6 +56,7 @@ int main(int argc, char* argv[]) {
blue = (unsigned short)(pixel & 0x001F); // 5
// Increase intensity and make rgb888
+ // TODO don't shift if maxval is set by depth
red = red << 3;
green = green << 2;
blue = blue << 3;
View
Binary file not shown.
View
Binary file not shown.

0 comments on commit 0777e28

Please sign in to comment.