예제 #1
0
파일: Highlighter.cpp 프로젝트: lixx2874/C-
void Highlighter::draw(PixelBuffer *background, int x, int y){
 
    for (int i=0; i<15; i++){
        for (int c = 0; c < 5; c++){
            ColorData get = background->getPixel(x-2+c, y-7+i);
  //          float s=0.2126*red + 0.7152*green + 0.0722*blue;
//            float i=s*0.4;
            const ColorData& color = ColorData(red * m_mask[i][c]*get.getLuminance()+ (1-m_mask[i][c]*get.getLuminance())* get.getRed(),green * m_mask[i][c]*get.getLuminance() + (1-m_mask[i][c]*get.getLuminance()) * get.getGreen(), blue *m_mask[i][c]*get.getLuminance() + (1-m_mask[i][c]*get.getLuminance()) * get.getBlue());
            background->setPixel(x-2+c,y-7+i,color);
		}
	}
}
예제 #2
0
void Tool::Apply(int x, int y, int m_height, PixelBuffer* m_displayBuffer, ColorData color)
{
	x = x - centerX;
	y = y + centerY;
	float trans;
	for (int i = 0; i < maskHeight; i++)
	{
		for (int j = 0; j < maskWidth; j++)
		{
      	                trans = mask[i][j];
			ColorData curColor = m_displayBuffer->getPixel(x + j, m_height - y + i);
			if (mask[i][j] < 1 && mask[i][j] > 0){
				trans = curColor.getLuminance() * mask[i][j];
				//std::cout << "High " << trans << std::endl;  //fot test only
                                //std::cout << "High2 " << mask[i][j] << std::endl;  //fot test only
			}
			m_displayBuffer->setPixel(x + j, m_height - y + i, color * trans + curColor * (1 - trans));
		}
	}
}
예제 #3
0
void Saturation::applyFilter(PixelBuffer* buffer, float saturation_amount)
{
    cout<<"Saturation";
	for (int x = 0; x < buffer->getWidth(); x ++)
    {
        for (int y = 0; y < buffer->getHeight(); y++)
        {
            ColorData currentColor = buffer->getPixel(x,y);
            float luminence = currentColor.getLuminance();
            ColorData newColor = ColorData(0,0,0);
            float redChannel = currentColor.getRed();
            float greenChannel = currentColor.getGreen();
            float blueChannel = currentColor.getBlue();
            float redDifference = (redChannel - luminence) * saturation_amount;
            float greenDifference = (greenChannel - luminence) * saturation_amount;
            float blueDifference = (blueChannel - luminence) * saturation_amount;
            newColor.setRed(luminence + redDifference);
            newColor.setGreen(luminence + greenDifference);
            newColor.setBlue(luminence + blueDifference);
            buffer->setPixel(x,y,newColor);
        }
    }
}