Skip to content

Instantly share code, notes, and snippets.

@Hermann-SW
Created September 22, 2020 10:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Hermann-SW/c6ecb46b6727e60bdc866756d9b4e164 to your computer and use it in GitHub Desktop.
Save Hermann-SW/c6ecb46b6727e60bdc866756d9b4e164 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#define N (32768+18580480)
int main(int argc, char* argv[])
{
FILE *src;
char c, *buf;
assert( argc == 2 );
assert( (src = fopen(argv[1], "rb")) );
assert( (buf = malloc(N)) );
assert( buf == memcpy(buf, "BRCM", 4) );
while (1)
{
while (!feof(src) && fgetc(src) != 'B') {}
if (feof(src)) return 1;
if ((c = fgetc(src)) == 'R')
if ((c = fgetc(src)) == 'C')
if ((c = fgetc(src)) == 'M')
{
assert(1 == fread(buf+4, N-4, 1, src));
assert(1 == fwrite(buf, N, 1, stdout));
return 0;
}
assert(c == ungetc(c, src));
}
}
@Hermann-SW
Copy link
Author

https://www.raspberrypi.org/forums/viewtopic.php?f=43&t=286001&p=1730777#p1730777

๐Ÿ“ raspistill -r -md 3 -w 4056 -h 3040 -o tst.jpg
๐Ÿ“ ./raw12MP tst.jpg > tst.raw
๐Ÿ“ dcraw tst.raw 
๐Ÿ“ file tst.ppm
tst.ppm: Netpbm image data, size = 4056 x 3040, rawbits, pixmap
๐Ÿ“ 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment