Watermarking at the Pixel Level

Watermarking 1-bit black and white images is a simple process of merging two images together. However, when working with multicolor images such as grayscale or full 24-bit color, it's not so easy. A simple merge will often add unwanted elements, such as a white background, from the watermark image file to the final image. Sidestepping this problem involves manipulating the image at the pixel level. Here's how with the RasterMaster imaging SDK:

//It will promote both images to 24 bpp in order to have accurate values.

//Then resize the WM image to given size[] values and match the common area

//of the Watermark and Main image at the given Watermark position.

public void imagec_imagec()

{

//Resize and promote image to same bit depth and given sizes

//get the valid watermark crop area. The area the wm shares with

//the main image

//get the corresponding main image y-axis start position

//Get proper buffer sizes with padding so as to not cause exception

//with the imglow_get_raster

//Loop from wm start y to end y. Increment main image ypos to keep up

for (int i=wmstarty; i= detect[DETECTBLUE][DETECTMIN]) &&

(b <= detect[DETECTBLUE][DETECTMAX]) &&

(g >= detect[DETECTGREEN][DETECTMIN]) &&

(g <= detect[DETECTGREEN][DETECTMAX]) &&

(r >= detect[DETECTRED][DETECTMIN]) &&

(r <= detect[DETECTRED][DETECTMAX])))

{

//Replace main image data with watermark image data

ibuff[startx] = wmbuff[ii];

ibuff[startx+1] = wmbuff[ii+1];

ibuff[startx+2] = wmbuff[ii+2];

}

startx += 3;

}

//Replace main image raster with modified raster

stat = Simage.IMGLOW_put_raster(starty, ibuff);

starty++;

}

}

Category:

Online Demo