Пример #1
0
void CImage::Contrast(float _fc)
{
	R_ASSERT(pData);

    // Apply contrast correction
    char *ptr       = (char *)pData;
    float fc        = _fc*2.f;
    for (u32 i=0; i<dwHeight; i++) {
		for (u32 j=0; j<dwWidth; j++) {
			BYTE *p = (BYTE *) &(ptr[i*dwWidth*4 + j*4]);
			p[0] = ClampColor(128.f + fc*(float(p[0]) - 128.f)); // red
			p[1] = ClampColor(128.f + fc*(float(p[1]) - 128.f)); // green
			p[2] = ClampColor(128.f + fc*(float(p[2]) - 128.f)); // blue
		}
    }
}
Пример #2
0
void SpotColor::DrawMsg(Int32 x1,Int32 y1,Int32 x2,Int32 y2, const BaseContainer &msg)
{
	OffScreenOn();
    Vector tmp = m_color.Convert(COLOR_SOURCE_DISPLAY).AsVector();
    ClampColor(tmp);
	DrawSetPen(tmp);
	DrawRectangle(x1,y1,x2,y2);
}
Пример #3
0
  static GPixel ColorToPixel(const GColor &c) {
    GColor dc = ClampColor(c);
    dc.fR *= dc.fA;
    dc.fG *= dc.fA;
    dc.fB *= dc.fA;

    return GPixel_PackARGB(static_cast<unsigned>((dc.fA * 255.0f) + 0.5f),
                           static_cast<unsigned>((dc.fR * 255.0f) + 0.5f),
                           static_cast<unsigned>((dc.fG * 255.0f) + 0.5f),
                           static_cast<unsigned>((dc.fB * 255.0f) + 0.5f));
  }
Пример #4
0
Bool SpotColor::InputEvent(const BaseContainer &msg)
{
	if(msg.GetInt32(BFM_INPUT_DEVICE) == BFM_INPUT_MOUSE){
		if(msg.GetInt32(BFM_INPUT_CHANNEL) == BFM_INPUT_MOUSELEFT){
			if(m_dragable){
				Vector col = m_color.Convert(COLOR_SOURCE_DISPLAY).AsVector();
                ClampColor(col);
				if(!HandleMouseDrag(msg,DRAGTYPE_RGB,&col,0)){
                    HandleClick();
                }
			}
		}
	}
	return FALSE;
}
Пример #5
0
void CImage::Grayscale()
{
	R_ASSERT(pData);

	char *ptr = (char *)pData;
	for (u32 i=0; i<dwHeight; i++) {
		for (u32 j=0; j<dwWidth; j++) {
            BYTE *p = (BYTE *) &(ptr[i*dwWidth*4 + j*4]);
			// Approximate values for each component's contribution to luminance.
			// Based upon the NTSC standard described in ITU-R Recommendation BT.709.
			float grey = float(p[0]) * 0.2125f + float(p[1]) * 0.7154f + float(p[2]) * 0.0721f;
			p[0] = p[1] = p[2] = ClampColor(grey);
		}
	}
}
vtkDataArray *
avtColorComposeExpression::DeriveVariable(vtkDataSet *in_ds, int currentDomainsIndex)
{
    size_t numinputs = varnames.size();

    //
    // Our first operand is in the active variable. We don't know if it's
    // point data or cell data, so check which one is non-NULL.
    //
    vtkDataArray *cell_data1 = in_ds->GetCellData()->GetArray(varnames[0]);
    vtkDataArray *point_data1 = in_ds->GetPointData()->GetArray(varnames[0]);
    vtkDataArray *data1 = NULL, *data2 = NULL, *data3 = NULL, *data4 = NULL;

    avtCentering centering;
    if (cell_data1 != NULL)
    {
        data1 = cell_data1;
        centering = AVT_ZONECENT;
    }
    else
    {
        data1 = point_data1;
        centering = AVT_NODECENT;
    }
    if (data1 != NULL && data1->GetNumberOfComponents() != 1)
    {
        EXCEPTION2(ExpressionException, outputVariableName, 
                   "The first variable is not a scalar.");
    }

    // Get the second variable.
    if (centering == AVT_ZONECENT)
        data2 = in_ds->GetCellData()->GetArray(varnames[1]);
    else
        data2 = in_ds->GetPointData()->GetArray(varnames[1]);

    if (data2 == NULL)
    {
        EXCEPTION2(ExpressionException, outputVariableName, 
                   "The first two variables have different centering.");
    }
    if (data2->GetNumberOfComponents() != 1)
    {
        EXCEPTION2(ExpressionException, outputVariableName, 
                   "The second variable is not a scalar.");
    }

    if (numinputs >= 3)
    {
        // Get the third variable.
        if (centering == AVT_ZONECENT)
            data3 = in_ds->GetCellData()->GetArray(varnames[2]);
        else
            data3 = in_ds->GetPointData()->GetArray(varnames[2]);
    
        if (data3 == NULL)
        {
            EXCEPTION2(ExpressionException, outputVariableName, 
                   "The first and third variables have different centering.");
        }
        if (data3->GetNumberOfComponents() != 1)
        {
            EXCEPTION2(ExpressionException, outputVariableName, 
                       "The third variable is not a scalar.");
        }
    }

    if (numinputs == 4)
    {
        // Get the fourth variable.
        if (centering == AVT_ZONECENT)
            data4 = in_ds->GetCellData()->GetArray(varnames[3]);
        else
            data4 = in_ds->GetPointData()->GetArray(varnames[3]);
    
        if (data4 == NULL)
        {
            EXCEPTION2(ExpressionException, outputVariableName, 
                   "The first and fourth variables have different centering.");
        }
        if (data4->GetNumberOfComponents() != 1)
        {
            EXCEPTION2(ExpressionException, outputVariableName, 
                       "The fourth variable is not a scalar.");
        }
    }

    vtkIdType nvals = data1->GetNumberOfTuples();
    vtkDataArray *dv = data1->NewInstance();
    dv->SetNumberOfComponents(4);
    dv->SetNumberOfTuples(data1->GetNumberOfTuples());
    if(numinputs == 1)
    {
        for(vtkIdType id = 0; id < nvals; ++id)
        {
            double val1 = ClampColor(data1->GetTuple1(id));
            dv->SetTuple4(id, val1, 0., 0., 255.);
        }
    }
    else if(numinputs == 2)
    {
        for(vtkIdType id = 0; id < nvals; ++id)
        {
            double val1 = ClampColor(data1->GetTuple1(id));
            double val2 = ClampColor(data2->GetTuple1(id));
            dv->SetTuple4(id, val1, val2, 0., 255.);
        }
    }
    else if(numinputs == 3)
    {
        for(vtkIdType id = 0; id < nvals; ++id)
        {
            double val1 = ClampColor(data1->GetTuple1(id));
            double val2 = ClampColor(data2->GetTuple1(id));
            double val3 = ClampColor(data3->GetTuple1(id));
            dv->SetTuple4(id, val1, val2, val3, 255.);
        }
    }
    else if(numinputs == 4)
    {
        for(vtkIdType id = 0; id < nvals; ++id)
        {
            double val1 = ClampColor(data1->GetTuple1(id));
            double val2 = ClampColor(data2->GetTuple1(id));
            double val3 = ClampColor(data3->GetTuple1(id));
            double val4 = ClampColor(data4->GetTuple1(id));
            dv->SetTuple4(id, val1, val2, val3, val4);
        }
    }

    return dv;
}
Пример #7
0
Color::Color(int r, int g, int b) {
	this->r = ClampColor(r);
	this->g = ClampColor(g);
	this->b = ClampColor(b);
}
Пример #8
0
void Color::SetBlue(int b) {
	this->b = ClampColor(b);
}
Пример #9
0
void Color::SetGreen(int g) {
	this->g = ClampColor(g);
}
Пример #10
0
void Color::SetRed(int r) {
	this->r = ClampColor(r);
}