Exemplo n.º 1
0
void CDrawUTwentyFourBppScreenBitmap::UpdateRect(const TRect& aRect) const
	{
	ASSERT(aRect.iTl.iX >= 0 && aRect.iTl.iY >= 0);
#if defined(_DEBUG)
	if (iOrientation&1)
		{
		ASSERT(aRect.iBr.iX <= iSize.iHeight);
		ASSERT(aRect.iBr.iY <= iSize.iWidth);
		}
	else
		{
		ASSERT(aRect.iBr.iX <= iSize.iWidth);
		ASSERT(aRect.iBr.iY <= iSize.iHeight);
		}
#endif
	TInt scanLineLen=iLongWidth*4;
	TInt srcPixelStep=4;
	TPoint srcStart(aRect.iTl);
	switch(iOrientation)
		{
	case CFbsDrawDevice::EOrientationRotated90:
		srcPixelStep=scanLineLen;
		scanLineLen=-4;
		srcStart.iX=iSize.iWidth-1-aRect.iTl.iY;
		srcStart.iY=aRect.iTl.iX;
		break;
	case CFbsDrawDevice::EOrientationRotated180:
		srcPixelStep=-4;
		scanLineLen=-scanLineLen;
		srcStart.iX=iSize.iWidth-1-aRect.iTl.iX;
		srcStart.iY=iSize.iHeight-1-aRect.iTl.iY;
		break;
	case CFbsDrawDevice::EOrientationRotated270:
		srcPixelStep=-scanLineLen;
		scanLineLen=4;
		srcStart.iX=aRect.iTl.iY;
		srcStart.iY=iSize.iHeight-1-aRect.iTl.iX;
		break;
		}
	TUint8* srcePtr = (TUint8*)PixelAddress(srcStart.iX,srcStart.iY);
	TUint8* srcePtrLimit = srcePtr + aRect.Width()*srcPixelStep;
	TInt rowMax = aRect.iTl.iY+aRect.Height();
	srcPixelStep-=3;	// as we increment while reading it
	for(TInt row = aRect.iTl.iY; row < rowMax; row++)
		{
		TUint8* tempSrcePtr = srcePtr;
		TUint8* destPixel = WinPixelAddress(aRect.iTl.iX,row);

		while (tempSrcePtr != srcePtrLimit)
 			{
			*destPixel++=*tempSrcePtr++;
			*destPixel++=*tempSrcePtr++;
			*destPixel++=*tempSrcePtr++;
			tempSrcePtr += srcPixelStep;
 			}
 		srcePtr+=scanLineLen;
 		srcePtrLimit+=scanLineLen;
		}
	}
Exemplo n.º 2
0
void CImage::SetSubImage(int xO, int yO, int width, int height)
{
    // NOTE:  the subimage is with respect to the rectangle specified
    //  by the origin and current shape
    int x = xO - origin[0];
    int y = yO - origin[1];

    // Adjust the start of memory pointer
    m_memStart = (char *) PixelAddress(x, y, 0);

    // Compute area of intersection and adjust the shape and origin
    int x1 = __min(m_shape.width,  x+width);    // end column
    int y1 = __min(m_shape.height, y+height);   // end row
    x = __max(0, __min(x, m_shape.width));      // clip to original shape
    y = __max(0, __min(y, m_shape.height));     // clip to original shape
    m_shape.width  = x1 - x;                    // actual width
    m_shape.height = y1 - y;                    // actual height
    origin[0] += x1;                            // adjust the origin
    origin[1] += y1;                            // adjust the origin
}
Exemplo n.º 3
0
void CImage::ClearPixels(void)
{
    // Set all the pixels to 0
    for (int y = 0; y < m_shape.height; y++)
        memset(PixelAddress(0, y, 0), 0, m_pixSize * m_shape.width);
}