Exemplo n.º 1
0
	void InitPalette()
	{
		int i, c1, c2, c3;
		int offset = nColorCount / 3;

		for (i=0; i < nColorCount; i++)
		{
			c1 = GetLuminance(i);
			c2 = GetLuminance(i+offset);
			c3 = GetLuminance(i+(offset*2));

			_pRgb[i] = RGB(c1, c2, c3);
		}
	}
Exemplo n.º 2
0
/////////////////////////////////////////////////////////
// processImage
//
/////////////////////////////////////////////////////////
void pix_lumaoffset :: processRGBAImage(imageStruct &image)
{
    const int nWidth = image.xsize;
    const int nHeight = image.ysize;
    if (!init) {
	init = 1;
    }
    U32*pSource = reinterpret_cast<U32*>(image.data);

    myImage.xsize = image.xsize;
    myImage.ysize = image.ysize;
    myImage.setCsizeByFormat(image.format);
    myImage.reallocate();
    U32*pOutput = reinterpret_cast<U32*>(myImage.data);

    const int nNumPixels=nWidth*nHeight;

    const int nOffsetScale=static_cast<int>(m_OffsetScale);
    const int nLineGap=static_cast<int>(m_LineGap);

    Pete_ZeroMemory(pOutput,(nNumPixels*sizeof(U32)));

    U32* pCurrentSource=pSource;
    U32* pCurrentOutput=pOutput;

    U32* pSourceEnd=(pSource+nNumPixels);
    U32* pOutputEnd=(pOutput+nNumPixels);

    if (!m_DoFilledLines) {
	while (pCurrentSource<pSourceEnd) {
	    const U32* pSourceLineEnd=pCurrentSource+nWidth;

	    while (pCurrentSource!=pSourceLineEnd) {
		const U32 SourceColour=*pCurrentSource;
		int nLuma=GetLuminance(SourceColour);
		nLuma-=(128*255);

		const int nOffset=(nLuma*nOffsetScale)>>16;
		U32*const pOffsetOutput=
			    pCurrentOutput+(nOffset*nWidth);

		if ((pOffsetOutput<pOutputEnd)&& (pOffsetOutput>=pOutput)) {

		    *pOffsetOutput=SourceColour;
		}

		pCurrentSource+=1;
		pCurrentOutput+=1;
	    }
	    pCurrentSource+=(nWidth*nLineGap);
	    pCurrentOutput+=(nWidth*nLineGap);
	}
    } else {
      if (hPreviousLineHeights==NULL || hPreviousLineHeights_size<static_cast<int>(nWidth*sizeof(U32*)) ){