示例#1
0
/////////////////////////////////////////////////////////
// do other processing here
//
/////////////////////////////////////////////////////////
int pix_colorreduce :: Pete_ColorReduce_Init()
{

  Pete_ColorReduce_DeInit();

  hRGBHistogram=Pete_NewHandle(cnGridCellCount*sizeof(int));
  if (hRGBHistogram==NULL) {
    Pete_ColorReduce_DeInit();
    return 0;
  }
  Pete_ZeroMemory((char*)Pete_LockHandle(hRGBHistogram),
                  cnGridCellCount*sizeof(int));

  hSortedColors=Pete_NewHandle(cnGridCellCount*sizeof(int*));
  if (hSortedColors==NULL) {
    Pete_ColorReduce_DeInit();
    return 0;
  }

  hInverseColorMap=
    Pete_NewHandle(cnGridCellCount*sizeof(SPete_ColorReduce_InverseMapEntry));

  if (hInverseColorMap==NULL) {
    Pete_ColorReduce_DeInit();
    return 0;
  }

  return 1;
}
示例#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*)) ){
示例#3
0
/////////////////////////////////////////////////////////
// processImage
//
/////////////////////////////////////////////////////////
void pix_backlight :: processRGBAImage(imageStruct &image)
{
    nWidth = image.xsize;
    nHeight = image.ysize;
    if (!init) {
	//Pete_BackLight_Init();
	init = 1;
    }
    pSource = (U32*)image.data;

    myImage.xsize = image.xsize;
    myImage.ysize = image.ysize;
    myImage.setCsizeByFormat(image.format);
    myImage.reallocate();

    pOutput = (U32*)myImage.data;

    const int nFixedShift=8;
//    const int nFixedMult=(1<<nFixedShift);

    const int nHalfWidth=(nWidth/2);
    const int nHalfHeight=(nHeight/2);

    const int nNumPixels = nWidth*nHeight;

    U32* pCurrentSource=pSource;
    U32* pCurrentOutput=pOutput;
    const U32* pSourceEnd=(pSource+nNumPixels);
//    const U32* pOutputEnd=(pOutput+nNumPixels);

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

    const int nSpikeScale=static_cast<int>(m_SpikeScale);
    const int nSpikeFloor=static_cast<int>(m_SpikeFloor);
    const int nSpikeCeiling=static_cast<int>(m_SpikeCeiling);

    int nY=0;
    while (pCurrentSource!=pSourceEnd) {

//	const U32* pSourceLineStart=pCurrentSource;
	const U32* pSourceLineEnd=pCurrentSource+nWidth;

	int nX=0;
	while (pCurrentSource!=pSourceLineEnd) {

	    U32 SourceColour=*pCurrentSource;

	    int nRed=(SourceColour&(0xff<<SHIFT_RED))>>SHIFT_RED;
	    int nGreen=(SourceColour&(0xff<<SHIFT_GREEN))>>SHIFT_GREEN;
	    int nBlue=(SourceColour&(0xff<<SHIFT_BLUE))>>SHIFT_BLUE;

	    int nLuminance =
			((90 * nRed)+
			(115 * nGreen)+
			(51 * nBlue));

	    nLuminance>>=8;
//			SourceColour|=(nLuminance<<24);

	    nLuminance=clampFunc(nLuminance,nSpikeFloor,nSpikeCeiling);
	    nLuminance-=nSpikeFloor;

	    const int nLength=((nLuminance*nSpikeScale)>>nFixedShift);

	    int nDeltaX=((nX-nHalfWidth)*nLength)>>8;
	    int nDeltaY=((nY-nHalfHeight)*nLength)>>8;

	    int nEndX=nX+nDeltaX;
	    if (nEndX>nWidth) {
		nEndX=nWidth;
	    } else if (nEndX<0) {
		nEndX=0;
	    }

	    int nEndY=nY+nDeltaY;
	    if (nEndY>nHeight) {
		nEndY=nHeight;
	    } else if (nEndY<0) {
		nEndY=0;
	    }

	    int nXInc;
	    if (nDeltaX<0) {
		nXInc=-1;
	    } else {
		nXInc=1;
	    }

	    int nYInc;
	    if (nDeltaY<0) {
		nYInc=-1;
	    } else {
		nYInc=1;
	    }

	    nDeltaX*=nXInc;
	    nDeltaY*=nYInc;

	    int nCurrentX=nX;
	    int nCurrentY=nY;

	    if ((nDeltaX==0)&&(nDeltaY==0)) {
		nDeltaX=1;
		nEndX+=1;
		nEndY+=1;
	    } else if (nDeltaX==0) {
		nEndX+=1;
	    } else if (nDeltaY==0) {
		nEndY+=1;
	    }

	    U32* pDest=(pOutput+(nCurrentY*nWidth)+nCurrentX);
	    const int nDestYInc=(nWidth*nYInc);
	    const int nDestXInc=nXInc;

	    if (nDeltaX>nDeltaY) {

		int	nCounter=nDeltaY;

		while ((nCurrentX!=nEndX)&&(nCurrentY!=nEndY)) {

#ifdef PETE_DEBUG_BACKLIGHT
		    if ((nCurrentX<0)||
			    (nCurrentX>=nWidth)||
			    (nCurrentY<0)||
			    (nCurrentY>=nHeight)||
			    (pDest<pOutput)||
			    (pDest>=pOutputEnd)) {

			while (true); // Pete- Infinite loop, easy way to tell if this triggered!

		    }
#endif // PETE_DEBUG_BACKLIGHT

		    const U32 DestColour=*pDest;
		    if (DestColour<SourceColour) {
			*pDest=SourceColour;
		    } else {
			break;
		    }

		    if (nCounter>=nDeltaX) {
			nCounter-=nDeltaX;
			nCurrentY+=nYInc;
			pDest+=nDestYInc;
		    }
		    nCurrentX+=nXInc;
		    pDest+=nDestXInc;

		    nCounter+=nDeltaY;

		}


	    } else {

		int	nCounter=nDeltaX;

		while ((nCurrentX!=nEndX)&&(nCurrentY!=nEndY)) {


#ifdef PETE_DEBUG_BACKLIGHT
		    if ((nCurrentX<0)||
			(nCurrentX>=nWidth)||
			(nCurrentY<0)||
			(nCurrentY>=nHeight)||
			(pDest<pOutput)||
			(pDest>=pOutputEnd)) {

			while (true); // Pete- Infinite loop, easy way to tell if this triggered!

		    }
#endif // PETE_DEBUG_BACKLIGHT

		    const U32 DestColour=*pDest;
		    if (DestColour<SourceColour) {
			*pDest=SourceColour;
		    } else {
			break;
		    }

		    if (nCounter>=nDeltaY) {
			nCounter-=nDeltaY;
			nCurrentX+=nXInc;
			pDest+=nDestXInc;
		    }
		    nCurrentY+=nYInc;
		    pDest+=nDestYInc;

		    nCounter+=nDeltaX;

		};

	    }

	    pCurrentSource+=1;
	    pCurrentOutput+=1;
	    nX+=1;

	}

	nY+=1;

    }
    image.data = myImage.data;
}