[Jderobot-admin] jderobot-r1222 - trunk/src/stable/components/introrob
redstar en jderobot.org
redstar en jderobot.org
Jue Abr 3 22:03:35 CEST 2014
Author: redstar
Date: 2014-04-03 22:03:35 +0200 (Thu, 03 Apr 2014)
New Revision: 1222
Modified:
trunk/src/stable/components/introrob/gui.cpp
trunk/src/stable/components/introrob/gui.h
Log:
#209 Fixed tabs <-> spaces and ratio when images are smaller than widget
Modified: trunk/src/stable/components/introrob/gui.cpp
===================================================================
--- trunk/src/stable/components/introrob/gui.cpp 2014-04-03 19:55:41 UTC (rev 1221)
+++ trunk/src/stable/components/introrob/gui.cpp 2014-04-03 20:03:35 UTC (rev 1222)
@@ -450,21 +450,25 @@
if (gtk_image1->get_width() < api->imgBuff->get_width() ||
gtk_image1->get_height() < api->imgBuff->get_height()) {
// Cambiamos la resolución manteniendo la relación de aspecto
- image1_ratio = Gui::getAspectRatio(api->imgBuff->get_width(), api->imgBuff->get_height(),
- gtk_image1->get_width(), gtk_image1->get_height());
+ image1_ratio = Gui::getAspectRatio(api->imgBuff->get_width(), api->imgBuff->get_height(),
+ gtk_image1->get_width(), gtk_image1->get_height());
api->imgBuff = api->imgBuff->scale_simple(api->imgBuff->get_width() / image1_ratio,
- api->imgBuff->get_height() / image1_ratio, Gdk::INTERP_BILINEAR);
- }
+ api->imgBuff->get_height() / image1_ratio, Gdk::INTERP_BILINEAR);
+ } else {
+ image1_ratio = 1;
+ }
gtk_image1->set(api->imgBuff);
gtk_image2->clear();
if (gtk_image2->get_width() < api->imgBuff2->get_width() ||
gtk_image2->get_height() < api->imgBuff2->get_height()) {
// Cambiamos la resolución manteniendo la relación de aspecto
- image2_ratio = Gui::getAspectRatio(api->imgBuff2->get_width(), api->imgBuff2->get_height(),
- gtk_image2->get_width(), gtk_image2->get_height());
+ image2_ratio = Gui::getAspectRatio(api->imgBuff2->get_width(), api->imgBuff2->get_height(),
+ gtk_image2->get_width(), gtk_image2->get_height());
api->imgBuff2 = api->imgBuff2->scale_simple(api->imgBuff2->get_width() / image2_ratio,
- api->imgBuff2->get_height() / image2_ratio, Gdk::INTERP_BILINEAR);
- }
+ api->imgBuff2->get_height() / image2_ratio, Gdk::INTERP_BILINEAR);
+ } else {
+ image2_ratio = 1;
+ }
gtk_image2->set(api->imgBuff2);
}
@@ -530,10 +534,9 @@
api->x_click_cameraright = x;
api->y_click_cameraright = y;
-
- int offsetx = (gtk_image2->get_width() - gtk_image2->get_pixbuf()->get_width()) / 2;
+ int offsetx = (gtk_image2->get_width() - gtk_image2->get_pixbuf()->get_width()) / 2;
pixB.x = (x - offsetx) * image2_ratio;
- int offsety = (gtk_image2->get_height() - gtk_image2->get_pixbuf()->get_height()) / 2;
+ int offsety = (gtk_image2->get_height() - gtk_image2->get_pixbuf()->get_height()) / 2;
pixB.y = (y - offsety) * image2_ratio;
pixB.h = 1.0;
printf("click en camera derecha, punto %f,%f\n", pixB.x, pixB.y);
@@ -548,9 +551,9 @@
api->x_click_cameraleft = x;
api->y_click_cameraleft = y;
- int offsetx = (gtk_image1->get_width() - gtk_image1->get_pixbuf()->get_width()) / 2;
+ int offsetx = (gtk_image1->get_width() - gtk_image1->get_pixbuf()->get_width()) / 2;
pixA.x = (x - offsetx) * image1_ratio;
- int offsety = (gtk_image1->get_height() - gtk_image1->get_pixbuf()->get_height()) / 2;
+ int offsety = (gtk_image1->get_height() - gtk_image1->get_pixbuf()->get_height()) / 2;
pixA.y = (y - offsety) * image1_ratio;
pixA.h = 1.0;
printf("click en camera izquierda, punto %f,%f\n", pixA.x, pixA.y);
Modified: trunk/src/stable/components/introrob/gui.h
===================================================================
--- trunk/src/stable/components/introrob/gui.h 2014-04-03 19:55:41 UTC (rev 1221)
+++ trunk/src/stable/components/introrob/gui.h 2014-04-03 20:03:35 UTC (rev 1222)
@@ -166,7 +166,7 @@
// Cameras
Gtk::Image *gtk_image1;
Gtk::Image *gtk_image2;
- float image1_ratio, image2_ratio; // Size ratio: original image <-> GTK widget
+ float image1_ratio, image2_ratio; // Size ratio: original image <-> GTK widget
TPinHoleCamera myCamA, myCamB;
HPoint2D pixA; // for pixel projection
HPoint2D pixB; // for pixel projection
More information about the Jderobot-admin
mailing list