10 #include <QtCore/QtPlugin>
12 using namespace base::samples::frame;
18 image(0, 0, QImage::Format_RGB888),
22 resize(width(),height());
27 user_export_act->setStatusTip(tr(
"Emits an event for user specific export"));
34 setWindowTitle(tr(
"ImageView"));
74 int x = (int)(scale_x*(p.x()-offset_x)+0.5);
75 int y = (int)(scale_y*(p.y()-offset_y)+0.5);
77 bool valid = (x>=0 && x <=
source.width() &&
78 y>=0 && y <=
source.height());
82 x = x < 0 ? 0 :
source.width() - 1;
83 y = y < 0 ? 0 :
source.height() - 1;
87 return std::make_pair(QPoint(x, y), valid);
92 std::pair<QPoint, bool> img =
toImage(QPoint(event->x(),
event->y()));
99 if (event->modifiers() & Qt::ControlModifier)
110 std::pair<QPoint, bool> imgPoint =
toImage(QPoint(event->x(),
event->y()));
111 QPoint releasePoint = imgPoint.first;
112 int distance = (releasePoint -
pressPoint).manhattanLength();
115 int w = abs((
pressPoint - releasePoint).x()) + 1;
116 int h = abs((
pressPoint - releasePoint).y()) + 1;
117 int x = std::min(
pressPoint.x(), releasePoint.x());
118 int y = std::min(
pressPoint.y(), releasePoint.y());
128 static QColor background(127, 127, 127);
129 static QColor textcolor(255,255,255);
130 this->
originalImage = QImage(width(),height(),QImage::Format_RGB888);
132 painter.setBrush(background);
133 painter.drawRect(0,0,
image.width(),
image.height());
134 painter.setBrush(textcolor);
135 painter.drawText(0,0,
image.width(),
image.height(),
136 Qt::AlignVCenter|Qt::AlignHCenter,
"No Signal");
162 for(QList<DrawItem*>::iterator iter =
items.begin();iter !=
items.end();++iter) (*iter)->openGL(flag);
167 QString path = QFileDialog::getSaveFileName(
this, tr(
"Save File"),
169 tr(
"Images (*.png)"));
170 if(path.length() > 0)
179 temp.save(path,
"PNG",80);
182 image.save(path,
"PNG",80);
186 bool ImageViewOld::saveImage3(
const QString &mode,
int pixel_size,
int width,
int height,
const char* pbuffer, QString path, QString format)
189 frame_converter.copyFrameToQImageRGB888(image,mode, pixel_size, width, height,pbuffer);
190 image.save(path,format.toAscii().data(),80);
272 painter.setRenderHint(QPainter::TextAntialiasing,
true);
273 QList<DrawItem*>::iterator iter =
items.begin();
274 for(;iter !=
items.end();++iter)
277 if(!(*iter)->onOpenGL() || all ==
true)
285 QPainter painter(&image);
319 x = ((float)width())/
image.width();
320 y = ((float)height())/
image.height();
323 y_offset = 0.5f*(height()-x*
image.height());
325 x_offset = 0.5f*(width()-y*
image.width());
327 target.setRect(x_offset, y_offset, width()-x_offset*2, height()-y_offset*2);
333 QPainter painter(
this);
340 QWidget::resizeEvent(event);
void setZoomEnabled(bool enabled)
bool saveImage2(QString path, bool overlay=true)
std::pair< QPoint, bool > toImage(QPoint const &p)
void mouseReleaseEvent(QMouseEvent *event)
bool saveImage3(const QString &mode, int pixel_size, int width, int height, const char *pbuffer, QString path, QString format)
friend class ImageViewOldGL
void addRawImage(const QString &mode, int pixel_size, int width, int height, const char *pbuffer, const int size)
frame_helper::FrameQImageConverter frame_converter
ImageViewOld(QWidget *parent=NULL, bool use_openGL=false)
void drawDrawItemsToImage(QImage &image, bool all=false)
void contextMenuEvent(QContextMenuEvent *event)
void setGLViewPoint(int display_width=0, int display_height=0)
void setGroupStatus(int groupNr, bool enable)
virtual void resizeEvent(QResizeEvent *event)
ImageViewOldGL * image_view_gl
void mouseDoubleClickEvent(QMouseEvent *event)
virtual void openGL(bool flag)
void addImage(const QImage &image)
void crop(int x, int y, int w, int h)
void addFrame(const base::samples::frame::Frame &frame)
void mousePressEvent(QMouseEvent *event)
void setAspectRatio(bool value)
void clickImage(int x, int y)
virtual void paintEvent(QPaintEvent *event)
void drawDrawItemsToPainter(QPainter &painter, bool all=false)
QAction * user_export_act
void saveImage(bool overlay=true)