예제 #1
0
파일: sampleEffect.cpp 프로젝트: jjkrol/ZPR
void SampleEffect::execute(Photo * photo) {
  Glib::RefPtr<Gdk::Pixbuf> pixbuf = photo->getPixbuf();
  switch(operation){
    case VERTICAL:
      photo->setPixbuf(pixbuf->flip(false));
      break;
    case HORIZONTAL:
      photo->setPixbuf(pixbuf->flip(true));
      break;
    default:
      break;
  }
}
예제 #2
0
	Glib::RefPtr<Gdk::Pixbuf> gdkpixbuf_exif_rotate(const Glib::RefPtr<Gdk::Pixbuf> & tmp,
													int exif_orientation)
	{
		Glib::RefPtr<Gdk::Pixbuf> pixbuf;
		switch(exif_orientation) {
		case 0:
		case 1:
			pixbuf = tmp;
			break;
		case 2:
			pixbuf = tmp->flip(TRUE);
			break;
		case 3:
			pixbuf = tmp->rotate_simple(Gdk::PIXBUF_ROTATE_UPSIDEDOWN);
			break;
		case 4:
			pixbuf = tmp->rotate_simple(Gdk::PIXBUF_ROTATE_UPSIDEDOWN)->flip(TRUE);
			break;
		case 5:
			pixbuf = tmp->rotate_simple(Gdk::PIXBUF_ROTATE_CLOCKWISE)->flip(FALSE);
			break;
		case 6:
			pixbuf =  tmp->rotate_simple(Gdk::PIXBUF_ROTATE_CLOCKWISE);
			break;
		case 7:
			pixbuf =  tmp->rotate_simple(Gdk::PIXBUF_ROTATE_COUNTERCLOCKWISE)->flip(FALSE);
			break;
		case 8:
			pixbuf =  tmp->rotate_simple(Gdk::PIXBUF_ROTATE_COUNTERCLOCKWISE);
			break;
		default:
			break;
		}
		return pixbuf;
	}
예제 #3
0
void PhotoPrintOperation::on_draw_page(const Glib::RefPtr<Gtk::PrintContext>& Context, int PageNum) {
	if (!PixData || PixData->size()!=4)
		return;

	Cairo::RefPtr<Cairo::Context> CairoContext=Context->get_cairo_context();
	CairoContext->scale(1.0/CairoScale,1.0/CairoScale);

	if (Label) {
		Gdk::Cairo::set_source_pixbuf(CairoContext, Label, LabelArea.X, LabelArea.Y);
		CairoContext->paint();
	}

	/* Draw the photos */
	int Col=0, Row=0, MaxCol=1;
	time_t Timestamp=time(NULL);
	for (std::vector< Glib::RefPtr<Gdk::Pixbuf> >::iterator Pixbufi=PixData->begin();Pixbufi<PixData->end();Pixbufi++) {
		if (*Pixbufi) {
			ArchivePhoto(*Pixbufi,Timestamp,Row*2+Col);

			double PhotoScaleFactor;
			PhotoScaleFactor=std::min(PhotoArea[0].Width/(*Pixbufi)->get_width(),PhotoArea[0].Height/(*Pixbufi)->get_height());

			/* Scale the photo */
			Glib::RefPtr<Gdk::Pixbuf> ScaledPixbuf;
			ScaledPixbuf=(*Pixbufi)->scale_simple(
				(*Pixbufi)->get_width()*PhotoScaleFactor,
				(*Pixbufi)->get_height()*PhotoScaleFactor,
				Gdk::INTERP_BILINEAR);

			if (Cfg->GetFlipPrint())
				ScaledPixbuf=ScaledPixbuf->flip();

			Gdk::Cairo::set_source_pixbuf(CairoContext, ScaledPixbuf, PhotoArea[Col+2*Row].X, PhotoArea[Col+2*Row].Y);

			CairoContext->paint();
		}

		if (Col!=MaxCol) {
			Col++;
		} else {
			Col=0;
			Row++;
		}
	}

	if (Stamp) {
		double X,Y;
		X=PrintArea.X+Cfg->GetStampX()*PrintArea.Width-Stamp->get_width()/2.0;
		Y=PrintArea.Y+Cfg->GetStampY()*PrintArea.Height-Stamp->get_height()/2.0;
		Gdk::Cairo::set_source_pixbuf(CairoContext, Stamp, X, Y);

		CairoContext->paint();
	}
}
예제 #4
0
Gtk::Image * JToolbar::get_imagen(Glib::ustring file, bool flip){
    try{
        Glib::RefPtr<Gdk::Pixbuf> pixbuf = Gdk::Pixbuf::create_from_file(file);
        pixbuf = pixbuf->scale_simple(24, 24, Gdk::INTERP_BILINEAR);
        if (flip) {
            pixbuf = pixbuf->flip(true);}
        Gtk::Image *imagen = new Gtk::Image(pixbuf);
        return imagen;}
    catch(const Glib::FileError& e){
        std::cout << e.what() << std::endl;
        Gtk::Image *imagen = new Gtk::Image();
        return imagen;}}
예제 #5
0
bool PhotoPreview::on_draw(const Cairo::RefPtr<Cairo::Context>& cr) {
	if (!Image)
		return false;

	int Width,Height;
	Gtk::Allocation Allocation = get_allocation();
	Width=Allocation.get_width();
	Height=Allocation.get_height();

	if (Width<=1 || Height<=1)
		return false;

	/* Scale the photo */
	Glib::RefPtr<Gdk::Pixbuf> Scaled;

	/* Preserve aspect ratio */
	double ImageAspectRatio,PreviewAspectRatio;
	PreviewAspectRatio=(float)Width/Height;
	ImageAspectRatio=(float)Image->get_width()/Image->get_height();
	if (ImageAspectRatio<PreviewAspectRatio) {
		Width=Height*ImageAspectRatio;
	} else {
		Height=Width/ImageAspectRatio;
	}

	Scaled=Image->scale_simple(
		Width,
		Height,
		Gdk::INTERP_BILINEAR);

	if (Cfg->GetFlipPreview())
		Scaled=Scaled->flip();

	Gdk::Cairo::set_source_pixbuf(cr, Scaled,
		(Allocation.get_width()/2)-(Scaled->get_width()/2),
		(Allocation.get_height()/2)-(Scaled->get_height()/2)
		);
	cr->paint();

	double TimeLeft=Util::TimeDiff(&PhotoTime,NULL);
	double MinDim=get_width();
	if (get_height()<MinDim)
		MinDim=get_height();

	if (Overlay.length()==0 && TimeLeft>0) {
		double TotalTime=Cfg->GetCountdownCount()*(Cfg->GetCountdownTimeout()/1000.0);
		unsigned int Whole=floor(Cfg->GetCountdownCount()*TimeLeft/TotalTime);
		float Frac=(Cfg->GetCountdownCount()*TimeLeft/TotalTime)-Whole;

		Cairo::RefPtr<Cairo::Context> Context = get_window()->create_cairo_context();

		Context->set_source_rgba(1.0, 1.0, 1.0,0.5);
		Context->translate(get_width()/2.0,get_height()/2.0);

		/* Draw the fractional portion of the countdown */
		Context->save();
		Context->rotate(M_PI/2.0);
		Context->arc(0.0,0.0,MinDim/4.0,0,Frac*2*M_PI);
		Context->fill();
		Context->restore();

		/* Draw the Whole portion of the countdown */
		Context->save();
		Context->set_font_size(MinDim/2.0);
		char StrBuf[1024];
		snprintf(StrBuf,sizeof(StrBuf),"%d",Whole+1);
		Cairo::TextExtents Extents;
		Context->get_text_extents(StrBuf,Extents);
		Context->translate(-Extents.width/2.0,Extents.height/2.0);

		Context->show_text(StrBuf);
		Context->stroke();
		Context->restore();
	}

	if (Overlay.length()) {
		Cairo::RefPtr<Cairo::Context> Context = get_window()->create_cairo_context();
		Context->set_source_rgba(1.0, 1.0, 1.0,0.5);
		Context->translate(get_width()/2.0,get_height()/2.0);

		Context->save();
		Context->set_font_size(MinDim/2.0);
		Cairo::TextExtents Extents;
		Context->get_text_extents(Overlay,Extents);
		Context->translate(-Extents.width/2.0,Extents.height/2.0);

		Context->show_text(Overlay);
		Context->stroke();
		Context->restore();
	}

	return true;
}