The drop shadow is a silhouette that is lightened and blurred and appears behind the source object. It gives the illusion of depth to an image.
![]() Text with drop shadow |
|
![]() Sasafras Leaves |
![]() Leaves with drop shadow |
Two techniques are illustrated here --
int text_with_shadow(imgdes *resimg)
{
imgdes tmptext;
int rcode = NO_ERROR;
char *caption="Drop Shadow";
int textheight;
rcode = allocimage(&tmptext, 430, 86, 8);
if(rcode == NO_ERROR) {
zeroimage(255, &tmptext);
color = 0x808080; // Gray
textheight = 48; // 48 pt
tmptext.stx += 6; // Offset the shadow by (6,6)
tmptext.sty += 6;
addtext(color, textheight, "ARIAL BOLD", caption, &tmptext);
for(j=0; j<25; j++)
blur(&tmptext, &tmptext);
color = 0; // Black
tmptext.stx -= 6; // Restore starting position
tmptext.sty -= 6;;
freeimage(resimg); // Replace original image with this image
copyimgdes(&tmptext, resimg);
}
return(rcode);
}
// Creates a shadow of non-white portions of source image
int object_shadow(imgdes *srcimg, imgdes *desimg)
{
imgdes tmpsrc;
int rcode = NO_ERROR, j, shadow_width=20, shadow_height=20, cols, rows;
cols = CALC_WIDTH(srcimg);
rows = CALC_HEIGHT(srcimg);
allocimage(&tmpsrc, cols, rows, srcimg->bmh->biBitCount);
zeroimage(255, &tmpsrc);
tmpsrc.stx=shadow_width;
tmpsrc.sty=shadow_height;
copyimage(srcimg, &tmpsrc);
tmpsrc.stx = 0;
tmpsrc.sty = 0;
kodalith(254, &tmpsrc, &tmpsrc);
changebright(128, &tmpsrc, &tmpsrc);
for(j=0; j<25; j++)
blur(&tmpsrc, &tmpsrc);
multiplyimage(srcimg, &tmpsrc, desimg);
freeimage(&tmpsrc);
return(rcode);
}
Victor Image Processing Library homepage |
Victor Sample Code