int main(int argc, char **argv){
  clock_t t_ini, t_fin;
  double secs;

  t_ini = clock();
  bmp_info_header info;
  bmp_info_header info2;
  unsigned char *img;
  unsigned char *img2;

  //Imagenes del mismo tamaño
  img   = load_image("A.bmp", &info);
  img2  = load_image("B.bmp", &info2);

  printf("Mezclando...\n");
  mix(&info, &info2, img, img2);
  printf("Salvando...\n");
  save_bmp("test-mix.bmp", &info, img);
  printf("Grisando...\n");
  to_grayscale(&info, img);
  printf("Guardando resultado final...\n");
  save_bmp("test-grey.bmp", &info, img);

  free(img);
  free(img2);
  t_fin = clock();

  secs = (double)(t_fin - t_ini) / CLOCKS_PER_SEC;
  printf("%.16g milisegundos\n", secs * 1000.0);
  return 0;
}
Exemple #2
0
void Image_controls::set_thumbnail(const Image_buffer<rendering::Color4>& source, uint32_t channel, bool inverted, float modulate_factor)
{
	Image_buffer<rendering::Color4>& scratch_buffer = thumbnail_provider_->scratch_buffer();

	Channel_to_grayscale<rendering::Color4> to_grayscale(channel);
	to_grayscale.filter(scratch_buffer, source);

	if (inverted)
	{
		Invert<rendering::Color4> invert;
		invert.filter(scratch_buffer, scratch_buffer);
	}

	if (1.f != modulate_factor)
	{
		Modulate modulate(modulate_factor);
		modulate.filter(scratch_buffer, scratch_buffer);
	}

	const uint2& source_dimensions = source.dimensions();
	const uint2& thumbnail_dimensions = thumbnail_.dimensions();

	if (source_dimensions.x < thumbnail_dimensions.x || source_dimensions.y < thumbnail_dimensions.y)
	{
		Copy<rendering::Color4c> copy;
		copy.filter(thumbnail_, thumbnail_provider_->checkerboard());
	}

	// No need to swap channels for Qt here, as it is grayscale
	To_BGRA filter(false);
	filter.filter(thumbnail_, scratch_buffer, source.dimensions());

	QImage qimage(reinterpret_cast<const uchar*>(thumbnail_.data()),
				  thumbnail_dimensions.x, thumbnail_dimensions.y, QImage::Format_RGB32);

	QPixmap pixmap = QPixmap::fromImage(qimage);

	ui->image_label_->setPixmap(pixmap);
}