Exemplo n.º 1
0
static void lightencolor (int *col, float power)
{
	unsigned char *color;

	color = (unsigned char *) col;
	*color = lighten (*color, power);
	color++;
	*color = lighten (*color, power);
	color++;
	*color = lighten (*color, power);
	color++;
	*color = lighten (*color, power);
}
Exemplo n.º 2
0
void FEBlend::platformApplySoftware()
{
    FilterEffect* in = inputEffect(0);
    FilterEffect* in2 = inputEffect(1);

    ASSERT(m_mode > FEBLEND_MODE_UNKNOWN);
    ASSERT(m_mode <= FEBLEND_MODE_LIGHTEN);

    Uint8ClampedArray* dstPixelArray = createPremultipliedImageResult();
    if (!dstPixelArray)
        return;

    IntRect effectADrawingRect = requestedRegionOfInputImageData(in->absolutePaintRect());
    RefPtr<Uint8ClampedArray> srcPixelArrayA = in->asPremultipliedImage(effectADrawingRect);

    IntRect effectBDrawingRect = requestedRegionOfInputImageData(in2->absolutePaintRect());
    RefPtr<Uint8ClampedArray> srcPixelArrayB = in2->asPremultipliedImage(effectBDrawingRect);

    unsigned pixelArrayLength = srcPixelArrayA->length();
    ASSERT(pixelArrayLength == srcPixelArrayB->length());
    for (unsigned pixelOffset = 0; pixelOffset < pixelArrayLength; pixelOffset += 4) {
        unsigned char alphaA = srcPixelArrayA->item(pixelOffset + 3);
        unsigned char alphaB = srcPixelArrayB->item(pixelOffset + 3);
        for (unsigned channel = 0; channel < 3; ++channel) {
            unsigned char colorA = srcPixelArrayA->item(pixelOffset + channel);
            unsigned char colorB = srcPixelArrayB->item(pixelOffset + channel);
            unsigned char result;

            switch (m_mode) {
            case FEBLEND_MODE_NORMAL:
                result = normal(colorA, colorB, alphaA, alphaB);
                break;
            case FEBLEND_MODE_MULTIPLY:
                result = multiply(colorA, colorB, alphaA, alphaB);
                break;
            case FEBLEND_MODE_SCREEN:
                result = screen(colorA, colorB, alphaA, alphaB);
                break;
            case FEBLEND_MODE_DARKEN:
                result = darken(colorA, colorB, alphaA, alphaB);
                break;
            case FEBLEND_MODE_LIGHTEN:
                result = lighten(colorA, colorB, alphaA, alphaB);
                break;
            case FEBLEND_MODE_UNKNOWN:
            default:
                result = 0;
                break;
            }

            dstPixelArray->set(pixelOffset + channel, result);
        }
        unsigned char alphaR = 255 - ((255 - alphaA) * (255 - alphaB)) / 255;
        dstPixelArray->set(pixelOffset + 3, alphaR);
    }
}
Exemplo n.º 3
0
void HistogramView::paintEvent(QPaintEvent *evt)
{
	Q_UNUSED(evt)
	QPainter painter(this);

	QRect R(0,0,width(),height());
	if ((d->m_hovered)&&(!d->m_highlighted)) {
		painter.fillRect(R,QColor(150,150,150,80));
    }
	else if ((!d->m_hovered)&&(d->m_highlighted)) {
		painter.setPen(QPen(Qt::darkBlue,10));
		painter.drawRect(R);
	}
	else if ((d->m_hovered)&&(d->m_highlighted)) {
		painter.setPen(QPen(Qt::darkBlue,10));
		painter.drawRect(R);
		painter.fillRect(R,QColor(0,0,0,30));
	}
	else {

	}

	if (d->m_update_required) {
		d->update_bin_counts();
		d->m_update_required=false;
	}

	if (d->m_num_bins<=1) return;
	float spacing=d->m_bin_centers[1]-d->m_bin_centers[0];
	for (int i=0; i<d->m_num_bins; i++) {
		QPointF pt1=d->coord2pix(QPointF(d->m_bin_centers[i]-spacing/2,0));
		QPointF pt2=d->coord2pix(QPointF(d->m_bin_centers[i]+spacing/2,d->m_bin_counts[i]));
		QRectF R=make_rect(pt1,pt2);
		QColor col=d->m_fill_color;
        if (i==d->m_hovered_bin_index) col=lighten(col,15,15,15);
		painter.fillRect(R,col);
		painter.setPen(d->m_line_color);
		painter.drawRect(R);
    }

	if (!d->m_title.isEmpty()) {
		int text_height=12;
		QRect R(d->m_margin_left,5,this->width()-d->m_margin_left-d->m_margin_right,text_height);
		QFont font=painter.font();
		font.setFamily("Arial");
		font.setPixelSize(text_height);
		painter.setFont(font);
		painter.setPen(QColor(150,60,60));
		painter.drawText(R,d->m_title,Qt::AlignLeft|Qt::AlignTop);
	}
}
Exemplo n.º 4
0
void Board::paintEvent(QPaintEvent *e) {
  QPainter p;
  p.begin(this);
  for(int i = 0; i < x_tiles(); i++)
    for(int j = 0; j < y_tiles(); j++) {
      if(getField(i, j) == EMPTY)
	continue;

      int xpos = XBORDER + i * pm_tile[1]->width();
      int ypos = YBORDER + j * pm_tile[1]->height();
      QRect r(xpos, ypos, pm_tile[1]->width(), pm_tile[1]->height());
      if(e->rect().intersects(r)) {
	// check if it is a marked piece
	if(i == mark_x && j == mark_y) {
	    QPixmap *lpm = lighten(pm_tile[getField(i, j)-1]);
	    p.drawPixmap(xpos, ypos, *lpm);
	    delete lpm;
	} else
	  p.drawPixmap(xpos, ypos, *pm_tile[getField(i, j)-1]);
      }
    }
  p.end();
}
Exemplo n.º 5
0
void
goom_lines (GoomData * goomdata, gint16 data[2][512], unsigned int ID,
    unsigned int *p, guint32 power)
{
  guint32 color1;
  guint32 color2;
  guint32 resolx = goomdata->resolx;
  guint32 resoly = goomdata->resoly;
  unsigned char *color = 1 + (unsigned char *) &color1;

  switch (ID) {
    case 0:                    /* Horizontal stereo lines */
    {
      color1 = 0x0000AA00;
      color2 = 0x00AA0000;
      break;
    }

    case 1:                    /* Stereo circles */
    {
      color1 = 0x00AA33DD;
      color2 = 0x00AA33DD;
      break;
    }
    default:{
      color1 = color2 = 0;
      g_assert_not_reached ();
      break;
    }
  }
  *color = lighten (*color, power);
  color++;
  *color = lighten (*color, power);
  color++;
  *color = lighten (*color, power);
  color = 1 + (unsigned char *) &color2;
  *color = lighten (*color, power);
  color++;
  *color = lighten (*color, power);
  color++;
  *color = lighten (*color, power);

  switch (ID) {
    case 0:                    /* Horizontal stereo lines */
    {
      unsigned int i;

      for (i = 0; i < 512; i++) {
        guint32 plot;

        plot = i * resolx / 512 + (resoly / 4 + data[0][i] / 1600) * resolx;
        p[plot] = color1;
        p[plot + 1] = color1;
        plot = i * resolx / 512 + (resoly * 3 / 4 - data[1][i] / 1600) * resolx;
        p[plot] = color2;
        p[plot + 1] = color2;
      }
      break;
    }

    case 1:                    /* Stereo circles */
    {
      float z;
      unsigned int monX = resolx / 2;
      float monY = resoly / 4;
      float monY2 = resoly / 2;

      for (z = 0; z < 6.2832f; z += 1.0f / monY) {
        /* float offset1 = 128+data[1][(unsigned int)(z*81.33f)])/200000; */
        p[monX + (unsigned int) ((monY + ((float) resoly) * (128 +
                        data[1][(unsigned int) (z * 81.33f)]) / 200000) *
                cos (z) + resolx * (unsigned int) (monY2 + (monY +
                        ((float) resoly) * (128 +
                            data[1][(unsigned int) (z * 81.33f)]) / 400000) *
                    sin (z)))] = color1;
        p[monX + (unsigned int) ((monY - ((float) resoly) * (128 +
                        data[0][(unsigned int) (z * 81.33f)]) / 200000) *
                cos (z) + resolx * (unsigned int) (monY2 + (monY -
                        ((float) resoly) * (128 +
                            data[0][(unsigned int) (z * 81.33f)]) / 400000) *
                    sin (z)))] = color2;
      }
      break;
    }
  }
}