//1999-02-19,鲍捷,阴影效果 BOOL VPicEx::DropShadow() { imgdes *srcimg=GetImgDes(); imgdes tmpsrc, tmpmask; 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); allocimage(&tmpmask, cols, rows, srcimg->bmh->biBitCount); zeroimage(255, &tmpsrc); tmpsrc.stx=shadow_width; tmpsrc.sty=shadow_width; copyimage(srcimg, &tmpsrc); tmpsrc.stx = 0; tmpsrc.sty = 0; kodalith(230, &tmpsrc, &tmpsrc);//二值化,门限230 //门限以上的像素被认为白色,不产生阴影 negative(&tmpsrc, &tmpmask); changebright(128, &tmpsrc, &tmpsrc); for(j=0; j<10; j++) blur(&tmpsrc, &tmpsrc); //使阴影模糊。循环越多越模糊,扩散越大 tmpmask.stx=shadow_width; tmpmask.sty=shadow_width; addimage(&tmpsrc, &tmpmask, &tmpsrc); andimage(srcimg, &tmpsrc, srcimg); freeimage(&tmpmask); freeimage(&tmpsrc); return(rcode == NO_ERROR); }
//1999-02-09,鲍捷,浮雕效果 //只对灰度图像有效 BOOL VPicEx::TrueEmboss() { if( !IsValid() ) return FALSE; imgdes *srcimg=GetImgDes(); // colortogray(srcimg,srcimg); imgdes image1; imgdes image2; imgdes tmpsrc; int cols, rows, rcode; char kern1[10] = {-2,-2,0,-2,6,0,0,0,0,1}; char kern2[10] = {0,0,0,0,-6,2,0,2,2,1}; cols = CALC_WIDTH(srcimg); rows = CALC_HEIGHT(srcimg); allocimage(&tmpsrc, cols, rows, 8); // Assumes 8-bit source image copyimage(srcimg, &tmpsrc); allocimage(&image1, cols, rows, 8); allocimage(&image2, cols, rows, 8); matrixconv(kern1, &tmpsrc, &image1); matrixconv(kern2, &tmpsrc, &image2); zeroimage(128, &tmpsrc); addimage(&tmpsrc, &image1, &tmpsrc); subimage(&tmpsrc, &image2, &tmpsrc); rcode = copyimage(&tmpsrc, srcimg); // Assumes 8-bit result image freeimage(&image2); freeimage(&image1); freeimage(&tmpsrc); return(rcode == NO_ERROR); }
bool PageScene::init() { bool bRet = false; do { CC_BREAK_IF(!CCLayer::init()); //add close button CCMenuItemImage* pCloseItem = CCMenuItemImage::create( "CloseNormal.png", "CloseSelected.png", this, menu_selector(PageScene::menuCloseCallback)); CC_BREAK_IF(!pCloseItem); pCloseItem->setPosition(ccp(CCDirector::sharedDirector()->getWinSize().width - 20, 20)); CCMenu* pMenu = CCMenu::create(pCloseItem, NULL); CC_BREAK_IF(!pMenu); pMenu->setPosition(CCPointZero); this->addChild(pMenu, 1); //add words CCLabelTTF* pLabel = CCLabelTTF::create("PageScene", "Arial", 24); CC_BREAK_IF(!pLabel); CCSize size = CCDirector::sharedDirector()->getWinSize(); pLabel->setPosition(ccp(size.width / 2, size.height - 50)); this->addChild(pLabel, 1); addimage(); bRet = true; }while(0); return bRet; }