Beispiel #1
0
void NwSvgImage::draw()
{
	if( NULL == m_imgData.pImageSrc )
	{
		return ;
	}
	if( IMG_SRC_NURO_BMP == m_imgData.nImageSrcType )
	{
		PNUROBITMAP pBmp =(PNUROBITMAP)m_imgData.pImageSrc;
		if( IMG_PAINT_REPEAT == m_imgData.nImgPaintMode )
		{
			int nX = m_imgData.nDx; 
			int nY = m_imgData.nDy;
			int nXMax = m_imgData.nDx + m_imgData.nW;
			int nYMax = m_imgData.nDy + m_imgData.nH;
			while( nY < nYMax )
			{
				int nH = NURO_MIN(pBmp->bmpHeight, nYMax - nY);
				while( nX < nXMax )
				{
					int nW = NURO_MIN(pBmp->bmpWidth, nXMax - nX);
					vgWritePixels(pBmp->pBmpBuff, pBmp->bmpWidth*2, VG_sRGB_565
						, nX, nY, nW, nH);
					nX += nW;
				} 
				nY += nH;
			}
		}
		else
		{
			vgWritePixels(pBmp->pBmpBuff, pBmp->bmpWidth*2, VG_sRGB_565, m_imgData.nDx, m_imgData.nDy, m_imgData.nW, m_imgData.nH);
		}
	}
}
Beispiel #2
0
void ImageBufferData::transformColorSpace(const Vector<int>& lookUpTable)
{
    ASSERT(m_surface);

    VGint width = m_surface->width();
    VGint height = m_surface->height();

    VGubyte* data = new VGubyte[width * height * 4];
    VGubyte* currentPixel = data;

    m_surface->makeCurrent();

    vgReadPixels(data, width * 4, IMAGEBUFFER_VG_EXCHANGE_FORMAT, 0, 0, width, height);
    ASSERT_VG_NO_ERROR();

    for (int y = 0; y < height; y++) {
        for (int x = 0; x < width; currentPixel += 4, x++) {
            currentPixel[IMAGEBUFFER_A] = lookUpTable[currentPixel[IMAGEBUFFER_A]];
            currentPixel[IMAGEBUFFER_R] = lookUpTable[currentPixel[IMAGEBUFFER_R]];
            currentPixel[IMAGEBUFFER_G] = lookUpTable[currentPixel[IMAGEBUFFER_G]];
            currentPixel[IMAGEBUFFER_B] = lookUpTable[currentPixel[IMAGEBUFFER_B]];
        }
    }

    vgWritePixels(data, width * 4, IMAGEBUFFER_VG_EXCHANGE_FORMAT, 0, 0, width, height);
    ASSERT_VG_NO_ERROR();

    delete[] data;
}
Beispiel #3
0
void ImageBufferData::putImageData(ImageData*& source, const IntRect& sourceRect, const IntPoint& destPoint, const IntSize& size, VGImageFormat format)
{
    ASSERT(m_surface);

    ASSERT(sourceRect.width() > 0);
    ASSERT(sourceRect.height() > 0);

    // We expect the sourceRect to be a subset of the given source image.
    ASSERT(sourceRect.x() >= 0);
    ASSERT(sourceRect.y() >= 0);
    ASSERT(sourceRect.right() <= source->width());
    ASSERT(sourceRect.bottom() <= source->height());

    // The target origin point is the combined offset of sourceRect.location()
    // and destPoint.
    int destx = destPoint.x() + sourceRect.x();
    int desty = destPoint.y() + sourceRect.y();
    ASSERT(destx >= 0);
    ASSERT(desty >= 0);
    ASSERT(destx + sourceRect.width() <= size.width());
    ASSERT(desty + sourceRect.height() <= size.height());

    unsigned const char* data = source->data()->data()->data();
    int dataOffset = (sourceRect.y() * source->width() * 4) + (sourceRect.x() * 4);

    m_surface->makeCurrent();

    vgWritePixels(data + dataOffset, source->width() * 4, format,
        destx, desty, sourceRect.width(), sourceRect.height());
    ASSERT_VG_NO_ERROR();
}