unsigned char pixel_intensity[] to image; C code, Linux
问题 I have a data array of pixel intensity (e.g. unsigned char pixel_intensity[4] = {0, 255, 255, 0} ) and I need to create image in C code on Linux (Raspberry Pi). What is the easiest way to do it? 回答1: I would suggest using the netpbm format as it is very easy to program. It is documented here and here. I have written a little demonstration of how to write a simple greyscale ramp to a 100x256 image below. #include <stdio.h> #include <stdlib.h> int main(){ FILE *imageFile; int x,y,pixel,height