Setting new color to a pixel

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
rohitkrishna
Posts: 43
Joined: 2011-10-01T14:34:04-07:00
Authentication code: 8675308

Setting new color to a pixel

Post by rohitkrishna »

Hi everyone...

Iam trying to use PixelSetRed(),PixelSetGreen(),PixelSetBlue() functions...to change the r,g,b of a particular pixel...iam storing the actual r,g,b values in an array and manipulating them and then trying to produce an image with the modified values...I divided the image into sub-images(this is a requirement)..

Code: Select all

a=0;
	while(a<v.n_sbimg)
	{
		modify_iterator=NewPixelRegionIterator(modify_wand,v.col[a],v.row[a],v.sbimg_wdt,v.sbimg_hgt);
		for(y=0;y<v.sbimg_hgt;y++)
		{
			modify_pixels = PixelGetNextIteratorRow(modify_iterator, &v.sbimg_wdt);
			for(x=0;x<v.sbimg_wdt;x++)
			{
				PixelSetRed(modify_pixels[x],pxl_data[(loc(y,x,v.sbimg_wdt)+ a*v.sbimg_pxl)]); //pxl_data is a 1-D array containing r,g,b values                      sub-image wise..Iam retreving the values using a macro
				PixelSetGreen(modify_pixels[x],pxl_data[(loc(y,x,v.sbimg_wdt)+1+ a*v.sbimg_pxl)]);
				PixelSetBlue(modify_pixels[x],pxl_data[(loc(y,x,v.sbimg_wdt)+2+ a*v.sbimg_pxl)]);
				PixelSyncIterator(modify_iterator);
			}
		}
	a++;
	}
Can anyone please tell me why iam not getting the desired output..?
Post Reply