int main(int argc, char *argv[]) {
	init_imgproc();
	Viewer *view = viewOpen(200, 200, "Sails");
	Image *img = imgFromBitmap(argv[1]);
	
	for (int x = 0; x < img -> width; x++) {
		for (int y = 0; y < img -> height; y++) {
			char * pixel = imgGetPixel(img, x, y);
			char red = pixel[2];
			char green = pixel[1];
			char blue = pixel[0];
			
			if (red > green && red > blue) {
				imgSetPixel(img, x, y, 255, 0, 0);
			} else if (green > red && green > blue) {
				imgSetPixel(img, x, y, 0, 255, 0);
			} else {
				imgSetPixel(img, x, y, 0, 0, 255);
		
			}
		}
	}

	viewDisplayImage(view, img);
	waitTime(5000); 
	imgDestroy(img);
	viewClose(view);
	quit_imgproc();
	return 0;
}
Beispiel #2
0
			donebytes += rc;
		}
		imgDestroy(img);
		close(fdw);
		return 0;
	} 
	else 														//parent process
	{
		close(fdw);
		uint32_t *fromlogic;
		char *buf;
		int rc, donebytes;
		Image * img = imgFromBitmap("lena.bmp");
	  	int pixel_count = img->width*img->height;
		uint32_t bytes_count = pixel_count*sizeof(uint32_t);
		Viewer * view = viewOpen(img->width, img->height, "First");
		viewDisplayImage(view, img);
		waitTime(2000);
		viewClose(view);
	    fromlogic = malloc(bytes_count);
	    if (!fromlogic) 
	    {
	      printf("Failed to allocate memory\n");
	      exit(1);
	    }
	    buf = (char *) fromlogic;
	    donebytes = 0;
	    while (donebytes < bytes_count)							//loop care about writing all bytes to PL
	    {
			rc = read(fdr, buf + donebytes, bytes_count - donebytes);
			if ((rc < 0) && (errno == EINTR))	continue;