Oscar Software Framework Manual JPEG Encoding Module
sparre edited this page Apr 5, 2013
·
6 revisions
Go to Table of Contents.
This module allows images to be compressed into a JPEG image. A raw image which is supplied to the module's encoding function as an OSC_PICTURE is compressed according to a compression factor and written into the supplied buffer. This data may then be written directly into a file to form a valid JPEG image.
- log: For logging.
{ unsigned char *jpgPicEnd, jpgbuf[500000]; /* (1) */ struct OSC_PICTURE pic; colpic.data = picture_data; /* (2) */ colpic.type = OSC_PICTURE_BGR_24; colpic.width = picture_width; colpic.height = picture_height; jpgPicEnd = OscJpgEncode(&colpic, jpgbuf, 1024); /* (3) */ fp = fopen (filename, "wb"); /* (4) */ fwrite (jpgbuf, 1, jpgPicEnd - jpgbuf, fp); fclose(fp); }
- Allocate enough memory for the final image.
- Contruct the OSC_PICTURE struct.
- Encode the image.
- Write the encoded image to a file.