Beispiel #1
0
void CItemDlg::OnLbnSelchangeItmItemList()
{
	// TODO: 在此添加控件通知处理程序代码
	GetPrice();
	SetPrice();
	SetDesc();
}
Beispiel #2
0
	Ptr<Texture> HeightToBumpTex(const Ptr<Texture> & heightTex, float scale)
	{
		auto bumpTexDesc = heightTex->GetDesc();
		bumpTexDesc.format = RENDER_FORMAT_R8G8B8A8_UNORM;
		bumpTexDesc.bindFlag = TEXTURE_BIND_SHADER_RESOURCE | TEXTURE_BIND_RENDER_TARGET | TEXTURE_BIND_GENERATE_MIPS;
		bumpTexDesc.mipLevels = 0;
		auto bumpTex = Global::GetRenderEngine()->GetRenderFactory()->CreateTexture(TEXTURE_2D);
		bumpTex->SetDesc(bumpTexDesc);
		bumpTex->Init();

		auto ps = Shader::FindOrCreate<HeightToBumpPS>();

		ps->SetScalar("texSize", heightTex->GetTexSize());
		ps->SetScalar("scale", scale);

		ps->SetSRV("heightTex", heightTex->GetShaderResourceView());

		ps->SetSampler("pointSampler", SamplerTemplate<FILTER_MIN_MAG_MIP_POINT>::Get());

		ps->Flush();

		DrawQuad({ bumpTex->GetRenderTargetView(0, 0, 1) });

		bumpTex->GenerateMips();

		return bumpTex;
	}
Beispiel #3
0
	String ShininessToRoughnessTex(const String & path)
	{
		auto roughnessTexPath = path.substr(0, path.rfind('.')) + "_roughness" + TextureAsset::GetExtension();
		if (Global::GetPlatform()->FileExists(roughnessTexPath))
			return roughnessTexPath;

		auto shininessTexAsset = Asset::Find<TextureAsset>(path);
		if (!shininessTexAsset->IsInit())
		{
			shininessTexAsset->Init();

			auto roughnessTexDesc = shininessTexAsset->GetTexture()->GetDesc();
			roughnessTexDesc.bindFlag = TEXTURE_BIND_SHADER_RESOURCE | TEXTURE_BIND_RENDER_TARGET | TEXTURE_BIND_GENERATE_MIPS;
			roughnessTexDesc.mipLevels = 0;
			auto roughnessTex = Global::GetRenderEngine()->GetRenderFactory()->CreateTexture(TEXTURE_2D);
			roughnessTex->SetDesc(roughnessTexDesc);
			roughnessTex->Init();

			auto ps = Shader::FindOrCreate<ShininessToRoughnessPS>();
			ps->SetSRV("shininessTex", shininessTexAsset->GetTexture()->GetShaderResourceView(0, 1, 0, 1));
			ps->SetSampler("pointSampler", SamplerTemplate<FILTER_MIN_MAG_MIP_POINT>::Get());
			ps->Flush();

			DrawQuad({ roughnessTex->GetRenderTargetView(0, 0, 1) });

			auto roughnessTexAsset = std::make_shared<TextureAsset>();
			roughnessTexAsset->SetPath(roughnessTexPath);
			roughnessTexAsset->Register();
			roughnessTexAsset->Save();
		}

		return roughnessTexPath;
	}
Beispiel #4
0
CZPtCloudPoint::CZPtCloudPoint(const CZPtCloudPoint& oPtCloudPoint)
{
    x = oPtCloudPoint.GetX();
    y = oPtCloudPoint.GetY();
    z = oPtCloudPoint.GetZ();
    m_nRedValue = oPtCloudPoint.GetRedValue();
    m_nGreenValue = oPtCloudPoint.GetGreenValue();
    m_nBlueValue = oPtCloudPoint.GetBlueValue();
    m_nAlphaValue = oPtCloudPoint.GetAlphaValue();
    SetDesc(oPtCloudPoint.GetDesc());
}
Beispiel #5
0
void CItemDlg::OnConfigChanged(BOOL bRomChanged, BOOL bUILangChanged)
{
	SetItemList();
	SetDesc();

	if(bRomChanged)
	{
		m_ctrlConfirm.EnableWindow(!rom.m_bIsFileReadOnly);

		SetPrice();
	}
}
Beispiel #6
0
///////////////////////////////////////////////////////////////////////
// CChart::Convert
// Create CChart with input record string; Return NULL if invalid
//
BOOL CChart::Convert( const char* pszChartFileRecord )
{
    ASSERT_VALID( this );
    BOOL match, done;
    int field, sidx, slen;

    CString s = CString( pszChartFileRecord );
    slen = s.GetLength();
    done = FALSE;
    sidx = 0;

    for( field=0; done == FALSE; field++ )
    {
	match = FALSE;
	switch( field )
	{
	case 0: /* "a," */
	    if ( s.Left(2) == "a," ) match = TRUE;
	    sidx += 2;
	    break;

	case 1: /* account no. - X, XX, or XXX, */
	    match = SetChartAcct( (s.Mid( sidx )).SpanExcluding(","));
	    sidx += m_ChartAcct.GetLength() + 1;
	    break;

	case 2: /* description - XX...X, or XX...X\n */
	    match = SetDesc( (s.Mid( sidx )).SpanExcluding(",\n") );
	    sidx += GetDesc().GetLength() + 1;
	    if ( sidx-1 >= slen || s[sidx-1] == '\n' ) done = TRUE;
	    break;

	case 3: /* Old account - NULL X XX XXX followed by , or \n */
	    match = SetOldAcct( (s.Mid( sidx )).SpanExcluding(",\n") );
	    sidx += m_OldAcct.GetLength() + 1;
	    if( sidx-1 >= slen || s[sidx-1] == '\n' ) done = TRUE;
	    break;

	case 4: /* Summary Account Flag - NULL\n or s\n */
	    //cerr << "\"" << (s.Mid( sidx )).SpanExcluding("\n") "\"\n";
	    match = SetSummaryAcct( (s.Mid( sidx )).SpanExcluding("\n") );
	    if ( sidx >= slen || s[sidx] == '\n' || s[sidx+1] == '\n' ) done = TRUE;
	    break;

	} // switch
	if( match == FALSE ) {
	    cerr << pszChartFileRecord
		 << "Invalid Chart Record\n";
	    done = TRUE;
	}
    } // for
    return match;
} // function
Beispiel #7
0
void MeaPositionLogMgr::Position::Load(const MeaXMLNode* positionNode)
{
    bool def;

    for (MeaXMLNode::NodeIter_c iter = positionNode->GetChildIter(); !positionNode->AtEnd(iter); ++iter) {
        MeaXMLNode* node = *iter;

        if (node->GetType() == MeaXMLNode::Element) {
            if (node->GetData() == _T("desc")) {
                SetDesc(ProcessDataNodes(node));
            } else if (node->GetData() == _T("points")) {
                for (MeaXMLNode::NodeIter_c pointIter = node->GetChildIter(); !node->AtEnd(pointIter); ++pointIter) {
                    MeaXMLNode* pointNode = *pointIter;
                    const MeaXMLAttributes& attrs = pointNode->GetAttributes();

                    if ((pointNode->GetType() == MeaXMLNode::Element) && (pointNode->GetData() == _T("point"))) {
                        CString name;
                        FPOINT pt;
                        attrs.GetValueStr(_T("name"), name, def);
                        attrs.GetValueDbl(_T("x"), pt.x, def);
                        attrs.GetValueDbl(_T("y"), pt.y, def);
                        AddPoint(name, pt);
                    }
                }
            } else if (node->GetData() == _T("properties")) {
                for (MeaXMLNode::NodeIter_c pointIter = node->GetChildIter(); !node->AtEnd(pointIter); ++pointIter) {
                    MeaXMLNode* pointNode = *pointIter;
                    const MeaXMLAttributes& attrs = pointNode->GetAttributes();

                    if (pointNode->GetType() == MeaXMLNode::Element) {
                        if (pointNode->GetData() == _T("width")) {
                            attrs.GetValueDbl(_T("value"), m_width, def);
                            m_fieldMask |= MeaWidthField;
                        } else if (pointNode->GetData() == _T("height")) {
                            attrs.GetValueDbl(_T("value"), m_height, def);
                            m_fieldMask |= MeaHeightField;
                        } else if (pointNode->GetData() == _T("distance")) {
                            attrs.GetValueDbl(_T("value"), m_distance, def);
                            m_fieldMask |= MeaDistanceField;
                        } else if (pointNode->GetData() == _T("area")) {
                            attrs.GetValueDbl(_T("value"), m_area, def);
                            m_fieldMask |= MeaAreaField;
                        } else if (pointNode->GetData() == _T("angle")) {
                            attrs.GetValueDbl(_T("value"), m_angle, def);
                            m_fieldMask |= MeaAngleField;
                        }
                    }
                }
            }
        }
    }
}
Beispiel #8
0
void DFO_TableTranspose:: CalcOutput(FOcalcType  calcType)
{
    DoStatusChk();
    if (!StatusOK())
        return;

    int nchar = inputTableDC->GetStringLen();

    int noutputRows = ninputCols;
    if (skipXColumn)
        noutputRows--;
    int noutputCols = ninputRows;

    outputTableDC.Alloc(noutputCols, noutputRows, nchar);
    outputTableDC.columnDesc = inputTableDC->rowDesc;
    SetDesc(outputTableDC.columnDesc, "Column", noutputCols);


    SC_DoubleMatrix& outTable = outputTableDC.dataTable;
    const SC_DoubleMatrix& inTable = inputTableDC->dataTable;

    int nextOutRow = 0;
    for (int i = 0; i < ninputCols; i++)
    {
        if (skipXColumn && (xcolumnIndex == i))
            continue;

        outputTableDC.rowDesc += inputTableDC->columnDesc[i];

        for (int j = 0; j < ninputRows; j++)
            outTable[j][nextOutRow] = inTable[i][j];

        nextOutRow++;
    }
    SetDesc(outputTableDC.rowDesc, "Row", noutputRows);
    outputTableDC.SetSize(noutputCols, noutputRows);
}
Beispiel #9
0
int Object::LoadFrom(FILE *fl) {
  //static string debug_indent = "";

  int num, res;
  fscanf(fl, "%d ", &num);
  num2obj[num] = this;
  todo.push_back(this);

  memset(buf, 0, 65536);
  if(ver < 0x0015) {
    res = fscanf(fl, "%[^;]; ", buf);
    if(res < 1) fscanf(fl, " ; ");
    }
  else {
    num = 0;
    res = getc(fl);
    while(res > 0) { buf[num++] = res; res = getc(fl); }
    }
  SetShortDesc(buf);

  memset(buf, 0, 65536);
  if(ver < 0x0015) {
    res = fscanf(fl, "%[^;];\n", buf);
    if(res < 1) fscanf(fl, " ; ");
    }
  else {
    num = 0;
    res = getc(fl);
    while(res > 0) { buf[num++] = res; res = getc(fl); }
    }
  SetDesc(buf);

  memset(buf, 0, 65536);
  if(ver < 0x0015) {
    res = fscanf(fl, "%[^;]; ", buf);
    if(res < 1) fscanf(fl, " ; ");
    for(size_t i = 0; i < strlen(buf); ++i) {
      if(buf[i] == '\e') buf[i] = ';';
      }
    }
Beispiel #10
0
	const std::vector<Ptr<VertexBuffer>> & GetQuadVBs()
	{
		static std::vector<Ptr<VertexBuffer>> quadVBs;
		if (quadVBs.size() == 0)
		{
			// Postions
			{
				auto quadPositionVB = Global::GetRenderEngine()->GetRenderFactory()->CreateVertexBuffer();

				RenderBufferDesc desc;
				desc.bindFlag = BUFFER_BIND_VERTEX;
				desc.cpuAccess = 0;
				desc.elementSize = sizeof(float2);
				desc.numElements = 4;
				desc.bStructured = false;
				quadPositionVB->SetDesc(desc);

				VertexElementDesc elementDesc;
				elementDesc.bytesOffset = 0;
				elementDesc.bytesSize = sizeof(float2);
				elementDesc.format = RENDER_FORMAT_R32G32_FLOAT;
				elementDesc.name = "POSITION";
				elementDesc.index = 0;
				elementDesc.instanceDataRate = 0;
				quadPositionVB->SetElementsDesc({ elementDesc });

				float2 quadPositions[4] =
				{
					{ -1.0f,  1.0f },
					{ 1.0f,  1.0f },
					{ -1.0f, -1.0f },
					{ 1.0f, -1.0f }
				};
				quadPositionVB->Init(quadPositions);
				quadVBs.push_back(quadPositionVB);
			}

			// UVs
			{
				auto quadUVVB = Global::GetRenderEngine()->GetRenderFactory()->CreateVertexBuffer();

				RenderBufferDesc desc;
				desc.bindFlag = BUFFER_BIND_VERTEX;
				desc.cpuAccess = CPU_ACCESS_WRITE;
				desc.elementSize = sizeof(float2);
				desc.numElements = 4;
				desc.bStructured = false;
				quadUVVB->SetDesc(desc);

				VertexElementDesc elementDesc;
				elementDesc.bytesOffset = 0;
				elementDesc.bytesSize = sizeof(float2);
				elementDesc.format = RENDER_FORMAT_R32G32_FLOAT;
				elementDesc.name = "TEXCOORD";
				elementDesc.index = 0;
				elementDesc.instanceDataRate = 0;
				quadUVVB->SetElementsDesc({ elementDesc });

				quadUVVB->Init(nullptr);
				quadVBs.push_back(quadUVVB);
			}
		}

		return quadVBs;
	}
void 	correct (TrformStr *TrPtr, cPrefs *prefs)
{

    int 	i=0,j,k, kstart, kend, kdone, color;

    double 	scale_params[2];			// scaling factors for resize;
    double 	shear_params[2];			// shear values
    double	radial_params[6];			// coefficients for polynomial correction (0,...3)
    // and source width/2 (4) and correctionradius (5)
    double  lum_params[2];				// parameters to correct luminance variation

    struct  fDesc stack[10];            // Parameters for execute stack function
    struct  fDesc stackinv[10];         // Parameters for execute stack function

    int		destwidth, destheight;
    int 	xoff = 0, yoff = 0;
    int		sizesqr;

    double  xdoff, ydoff;
    Image	im, *dest, *src;
    fDesc	fD;
    fDesc	fDinv;

    im.data = NULL;

    src			= TrPtr->src;
    dest		= TrPtr->dest;

    // Apply filters, if required


    TrPtr->success = 1;

    if( prefs->luminance )
    {


        destwidth 		= TrPtr->src->width;
        destheight 		= TrPtr->src->height;

        // Allocate memory for destination image
        // If no further Xform: simply use SetDest

        if( !( 	prefs->resize 		||
                prefs->shear		||
                prefs->horizontal	||
                prefs->vertical 	||
                prefs->radial 		||
                prefs->cutFrame		||
                prefs->fourier)	)
        {
            if( SetDestImage(TrPtr, destwidth, destheight) != 0 )
            {
                TrPtr->success = 0;
                PrintError( "Not enough Memory.");
                return;
            }
        }
        else // Further Xform requested: use separate new image
        {
            memcpy( &im, TrPtr->src, sizeof(Image) );
            im.data = (unsigned char**) mymalloc( (size_t)im.dataSize );
            if( im.data == NULL )
            {
                TrPtr->success = 0;
                PrintError( "Not enough Memory.");
                return;
            }
            TrPtr->dest 	= &im;
        }

        // JMW 2003/08/25 Use the smaller of the width or height to
        // calculate luminance so that the same change is made to portrait and
        // landscape images.
        // MRDL 2003/08/25 Makes behavior consistent with lens distortion correction
        // algorithm
        if( TrPtr->src->width < TrPtr->src->height )
            sizesqr = (int)((TrPtr->src->width/2.0) * (TrPtr->src->width/2.0));
        else
            sizesqr = (int)((TrPtr->src->height/2.0) * (TrPtr->src->height/2.0));

        if( prefs->lum_params[0] ==  prefs->lum_params[1] &&
                prefs->lum_params[1] ==  prefs->lum_params[2] )  // Color independent
        {
            lum_params[0] =  - prefs->lum_params[0] / sizesqr;
            lum_params[1] =    prefs->lum_params[0] / 2.0 ;
            if( TrPtr->success != 0 )
            {
                filter( TrPtr, radlum, radlum16, (void*) lum_params, 0 );
            }
        }
        else // Color dependent
        {
            for(k=1; k<4; k++)
            {
                lum_params[0] =  - prefs->lum_params[k-1] / sizesqr;
                lum_params[1] =   prefs->lum_params[k-1] / 2.0 ;
                if( TrPtr->success != 0 )
                {
                    filter( TrPtr, radlum, radlum16, (void*) lum_params, k );
                }
            }
        }
    }

    if( TrPtr->success	&&  prefs->fourier )	// Fourier filtering required
    {
        if( prefs->luminance )
        {
            CopyImageData( src, &im );
            TrPtr->src = src;
        }

        if( prefs->fourier_mode == _fresize )
        {
            if( prefs->width == 0 && prefs->height == 0 )
            {
                TrPtr->success = 0;
                PrintError( "Zero Destination Image Size" );
                return;
            }

            if( prefs->width  )
                destwidth 		= prefs->width;
            else
                destwidth 		= (int)((double)TrPtr->src->width * (double)prefs->height / (double)TrPtr->src->height);

            if( prefs->height)
                destheight 		= prefs->height;
            else
                destheight		= (int)((double)TrPtr->src->height * (double)prefs->width / (double)TrPtr->src->width);
        }
        else
        {
            destwidth 		= TrPtr->src->width;
            destheight 		= TrPtr->src->height;
        }

        // Allocate memory for destination image
        // If no further Xform: simply use SetDest

        if( !( 	prefs->resize 		||
                prefs->shear		||
                prefs->horizontal	||
                prefs->vertical 	||
                prefs->radial 		||
                prefs->cutFrame	)	)
        {
            if( SetDestImage(TrPtr, destwidth, destheight) != 0 )
            {
                TrPtr->success = 0;
                PrintError( "Not enough Memory.");
                return;
            }
        }
        else // Further Xform requested: use separate new image
        {
            if( prefs->luminance )  // since then we have allocated im already
            {
                if( im.data ) myfree( (void**)im.data );
            }
            memcpy( &im, TrPtr->src, sizeof(Image) );
            im.width = destwidth;
            im.height = destheight;
            im.bytesPerLine = im.width * im.bitsPerPixel/8;
            im.dataSize = im.height * im.bytesPerLine;
            im.data = (unsigned char**) mymalloc( (size_t)im.dataSize );
            if( im.data == NULL )
            {
                TrPtr->success = 0;
                PrintError( "Not enough Memory.");
                return;
            }
            TrPtr->dest 	= &im;
        }

        fourier( TrPtr, prefs );
    }





    if( TrPtr->success		&&
            ( 	prefs->resize 		||
                prefs->shear		||
                prefs->horizontal	||
                prefs->vertical 	||
                prefs->radial 		||
                prefs->cutFrame)	)			// Displacement Xform requested
    {

        // First check whether recent luminance or fourier filtering
        if( prefs->luminance || prefs->fourier )
            TrPtr->src	= &im;

        TrPtr->dest = dest;

        // Set destination image parameters

        // most Xforms: dest = src

        destwidth 		= TrPtr->src->width;
        destheight 		= TrPtr->src->height;


        if( prefs->cutFrame )
        {
            if( getFrame( TrPtr->src, &xoff, &yoff, prefs->fwidth, prefs->fheight, TrPtr->mode & _show_progress ) != 0 )
            {
                TrPtr->success = 0;
                return;
            }
            //PrintError("x= %d, y= %d", xoff, yoff);
            destwidth 		=  prefs->fwidth ;
            destheight 		=  prefs->fheight ;
        }


        if(prefs->resize)
        {
            if( prefs->width == 0 && prefs->height == 0 )
            {
                TrPtr->success = 0;
                PrintError( "Zero Destination Image Size" );
                return;
            }

            if( prefs->width  )
                destwidth 		= prefs->width;
            else
                destwidth 		= (int)((double)TrPtr->src->width * (double)prefs->height / (double)TrPtr->src->height);

            if( prefs->height)
                destheight 		= prefs->height;
            else
                destheight		= (int)((double)TrPtr->src->height * (double)prefs->width / (double)TrPtr->src->width);
        }

        if( destwidth <= 0 || destheight <= 0 )
        {
            TrPtr->success = 0;
            PrintError( "Zero Destination Image Size" );
            return;
        }



        // Allocate memory for destination image

        if( SetDestImage(TrPtr, destwidth, destheight) != 0 )
        {
            TrPtr->success = 0;
            PrintError( "Not enough Memory.");
            goto _correct_exit;
        }



        // Check to see if the colors have the same or different displacement paras
        if( isColorSpecific( prefs ) )  // Color dependent
        {

            if( haveSameColorParas( prefs,0,1)) // R==G??
            {
                fprintf(stderr, "PT correct "PROGRESS_VERSION" R==G\n" );
                if( ! hasUsefulColorParas(prefs,0))
                {
                    fprintf(stderr, "Red/Green do NOTHING! Copying image data...\n" );
                    CopyImageData( TrPtr->dest, TrPtr->src );
                    fprintf(stderr, "Displacing just the Blue...\n" );
                    kstart=3;
                    kend  =3;
                }
                else if( ! hasUsefulColorParas(prefs,2))
                {
                    fprintf(stderr, "Blue does NOTHING! Copying image data...\n" );
                    CopyImageData( TrPtr->dest, TrPtr->src );
                    fprintf(stderr, "Displacing the Red/Green simultaneously...\n" );
                    kstart=4;
                    kend  =4;
                }
                else
                {
                    kstart=4;
                    kend  =3;
                }


            }
            else if( haveSameColorParas( prefs,1,2)) // G==B??
            {
                fprintf(stderr, "PT correct "PROGRESS_VERSION" G==B\n" );
                if( ! hasUsefulColorParas(prefs,1))
                {
                    fprintf(stderr, "Green/Blue do NOTHING! Copying image data...\n" );
                    CopyImageData( TrPtr->dest, TrPtr->src );
                    fprintf(stderr, "Displacing just the Red...\n" );
                    kstart=1;
                    kend  =1;
                }
                else if( ! hasUsefulColorParas(prefs,0))
                {
                    fprintf(stderr, "Red does NOTHING! Copying image data...\n" );
                    CopyImageData( TrPtr->dest, TrPtr->src );
                    fprintf(stderr, "Displacing the Green/Blue simultaneously...\n" );
                    kstart=6;
                    kend  =6;
                }
                else
                {
                    kstart=6;
                    kend  =1;
                }



            }
            else if( haveSameColorParas( prefs,2,0)) // R==B??
            {
                fprintf(stderr, "PT correct "PROGRESS_VERSION" R==B\n" );
                if( ! hasUsefulColorParas(prefs,0))
                {
                    fprintf(stderr, "Red/Blue do NOTHING! Copying image data...\n" );
                    CopyImageData( TrPtr->dest, TrPtr->src );
                    fprintf(stderr, "Displacing just the Green...\n" );
                    kstart=2;
                    kend  =2;
                }
                else if( ! hasUsefulColorParas(prefs,1))
                {
                    fprintf(stderr, "Green does NOTHING! Copying image data...\n" );
                    CopyImageData( TrPtr->dest, TrPtr->src );
                    fprintf(stderr, "Displacing the Red/Blue simultaneously...\n" );
                    kstart=5;
                    kend  =5;
                }
                else
                {
                    kstart=5;
                    kend  =2;
                }


            }
            else
            {
                fprintf(stderr, "PT correct "PROGRESS_VERSION" R!=G!=B\n" );
                if( ! hasUsefulColorParas(prefs,0))
                {
                    fprintf(stderr, "Red does NOTHING! Copying image data...\n" );
                    CopyImageData( TrPtr->dest, TrPtr->src );
                    fprintf(stderr, "Displacing the Green then Blue separately...\n" );
                    kstart=2;
                    kend  =3;
                }
                else if( ! hasUsefulColorParas(prefs,1))
                {
                    fprintf(stderr, "Green does NOTHING! Copying image data...\n" );
                    CopyImageData( TrPtr->dest, TrPtr->src );
                    fprintf(stderr, "Displacing the Blue then Red separately...\n" );
                    kstart=3;
                    kend  =1;
                }
                else if( ! hasUsefulColorParas(prefs,2))
                {
                    fprintf(stderr, "Blue does NOTHING! Copying image data...\n" );
                    CopyImageData( TrPtr->dest, TrPtr->src );
                    fprintf(stderr, "Displacing the Red then Green separately...\n" );
                    kstart=1;
                    kend  =2;
                }
                else
                {
                    kstart 	= 1;
                    kend	= 3;
                }

            }
        }
        else // Color independent
        {
            fprintf(stderr, "PT correct "PROGRESS_VERSION" R==G==B\n" );
            if( ! hasUsefulColorParas(prefs,0))
            {
                fprintf(stderr, "Red,Green,Blue do NOTHING! But you asked for it...\n" );
            }
            kstart	= 0;
            kend	= 0;
        }

        // Do the necessary displacements, either per color, 2-colors, or on all 3 colors.
        kdone=0;
        k=kstart;
        while(!kdone)
        {
            switch(k) // choose which color's paras to use
            {
            case 0: // RGB
                color = 0;// Use the Red paras
                break;

            case 1: // [0] = R
            case 2: // [1] = G
            case 3: // [2] = B
                color = k-1;
                break;

            case 4:// RG
                color=0;
                break;
            case 5:// RB
                color=0;
                break;
            case 6:// GB
                color=1;
                break;
            default:
                color=0;
                break;
            }

            i = 0;

            if( prefs->resize )
            {
                if(prefs->cutFrame)
                {
                    if( prefs->width )
                        scale_params[0] = ((double)prefs->fwidth)/ prefs->width;
                    else
                        scale_params[0] = ((double)prefs->fheight)/ prefs->height;

                    if( prefs->height )
                        scale_params[1] = ((double)prefs->fheight)/ prefs->height;
                    else
                        scale_params[1] = scale_params[0];
                }
                else
                {
                    if( prefs->width )
                        scale_params[0] = ((double)TrPtr->src->width)/ prefs->width;
                    else
                        scale_params[0] = ((double)TrPtr->src->height)/ prefs->height;

                    if( prefs->height )
                        scale_params[1] = ((double)TrPtr->src->height)/ prefs->height;
                    else
                        scale_params[1] = scale_params[0];
                }
                SetDesc(stack[i],resize,scale_params);
                i++;
            }

            // JMW 2008/01/03 make the order the same as Adjust doing correct
            if( prefs->radial )
            {
                switch( prefs->correction_mode)
                {
                case correction_mode_radial:
                    SetDesc(stack[i],radial, radial_params);
                    i++;
                    radial_params[4] = ( (double)( TrPtr->src->width < TrPtr->src->height ?
                                                   TrPtr->src->width : TrPtr->src->height) ) / 2.0;
                    break;
                case correction_mode_vertical:
                    SetDesc(stack[i],vertical, radial_params);
                    i++;
                    radial_params[4] = ((double)TrPtr->src->height) / 2.0;
                    break;
                case correction_mode_deregister:
                    SetDesc(stack[i],deregister, radial_params);
                    i++;
                    radial_params[4] = ((double)TrPtr->src->height) / 2.0;
                    break;
                }
                for(j=0; j<4; j++)
                    radial_params[j] = prefs->radial_params[color][j];
                radial_params[5] = prefs->radial_params[color][4];
            }

            if (prefs->vertical)
            {
                SetDesc(stack[i],vert,&(prefs->vertical_params[color]));
                i++;
            }

            if (prefs->horizontal)
            {
                SetDesc(stack[i],horiz,&(prefs->horizontal_params[color]) );
                i++;
            }

            if( prefs->shear )
            {
                shear_params[0] = prefs->shear_x / TrPtr->src->height;
                shear_params[1] = prefs->shear_y / TrPtr->src->width;
                SetDesc(stack[i],shear,shear_params);
                i++;
            }

            if( prefs->cutFrame )
            {
                if( xoff != 0 )
                {
                    xdoff = (double) xoff + 0.5 * ( prefs->fwidth - TrPtr->src->width ) ;
                    SetDesc(stack[i],horiz, &xdoff );
                    i++;
                }

                if( yoff != 0 )
                {
                    ydoff = (double)yoff + 0.5 * ( prefs->fheight - TrPtr->src->height) ;
                    SetDesc(stack[i],vert,&ydoff);
                    i++;
                }
            }

            stack[i].func = (trfn)NULL;

            if( 	!prefs->resize 		&&
                    !prefs->shear		&&
                    !prefs->horizontal	&&
                    !prefs->vertical 	&&
                    !prefs->radial 		&&
                    prefs->cutFrame )	// Only cutframe
            {
                ShiftImage(TrPtr, xoff, yoff);
            }
            else if( TrPtr->success != 0 && i != 0 )
            {
                // Copy and reverse the stack to make the inverse stack
                int ii = 0;
                while(i)
                {
                    stackinv[ii] = stack[i-1];
                    i--;
                    ii++;
                }
                stackinv[ii].func = (trfn)NULL;

                fD.func    = execute_stack_new;
                fD.param    = stack;
                fDinv.func = execute_stack_new;
                fDinv.param = stackinv;
                transFormEx( TrPtr, &fD, &fDinv, k, 1 );
                i = ii;
            }

            switch(k) // We use k as control var for a little statemachine:
            {
            case 0:// RGB
                kdone=1;
                break;

            case 1:// R
            case 2:// G
            case 3:// B
                if(k==kend)
                {
                    kdone=1;
                }
                else
                {
                    k++;

                    if(k==4)
                        k=1;
                }
                break;

            case 4:// RG
            case 5:// RB
            case 6:// GB
                if(k==kend)
                {
                    kdone=1;
                }
                else
                {
                    k=kend;
                }
                break;

            default:
                kdone=1;
                break;
            }

        }// END:while(!kdone)
    }


    if( !prefs->luminance && !prefs->fourier && !prefs->cutFrame && i == 0 ) // We did nothing!
    {
        TrPtr->success = 0;
    }

    if( TrPtr->success == 0 && ! (TrPtr->mode & _destSupplied))
        myfree( (void**)TrPtr->dest->data );

_correct_exit:

    TrPtr->src 		= src;
    TrPtr->dest 	= dest;


    if( im.data != NULL )
        myfree((void**)im.data);


}