ZDCPixmap::ZDCPixmap(const ZDCPixmap& iSource, const ZRectPOD& iSourceBounds) { ZRef<ZDCPixmapRep> sourceRep = iSource.GetRep(); if (not sourceRep) return; ZRectPOD originalBounds = sourceRep->GetBounds(); ZRectPOD realBounds = (iSourceBounds + LT(originalBounds)) & originalBounds; if (sIsEmpty(realBounds)) return; fRep = ZDCPixmapRep::sCreate( sourceRep->GetRaster(), realBounds, sourceRep->GetPixelDesc()); }
ZDCPixmap::ZDCPixmap(const ZDCPixmap& iSource1, const ZDCPixmap& iSource2, const ZDCPixmap& iMask) { // An undersized or missing image is considered to be all black, so a // missing mask means we're an exact copy of iSource1. if (not iMask) { fRep = iSource1.GetRep(); return; } ZPointPOD source1Size = iSource1.Size(); ZPointPOD source2Size = iSource2.Size(); ZPointPOD maskSize = iMask.Size(); ZPointPOD resultSize; resultSize.h = max(source1Size.h, max(source2Size.h, maskSize.h)); resultSize.v = max(source1Size.v, max(source2Size.v, maskSize.v)); EFormatStandard theStandardFormat = sMapEfficientToStandard(eFormatEfficient_Color_32); RasterDesc theRasterDesc(resultSize, theStandardFormat); PixelDesc thePixelDesc(theStandardFormat); fRep = ZDCPixmapRep::sCreate(theRasterDesc, sRect(resultSize), thePixelDesc); // Do a simple version for now for (ZCoord y = 0; y < resultSize.v; ++y) { for (ZCoord x = 0; x < resultSize.h; ++x) { ZRGBA source1Pixel = iSource1.GetPixel(x, y); ZRGBA source2Pixel = iSource2.GetPixel(x, y); ZRGBA maskPixel = iMask.GetPixel(x, y); this->SetPixel(x, y, source1Pixel * (ZRGBA::sWhite - maskPixel) + source2Pixel * maskPixel); } } }