本文整理汇总了C++中ImageView::pointImageTo方法的典型用法代码示例。如果您正苦于以下问题:C++ ImageView::pointImageTo方法的具体用法?C++ ImageView::pointImageTo怎么用?C++ ImageView::pointImageTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImageView
的用法示例。
在下文中一共展示了ImageView::pointImageTo方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: file
/* module functions */
static PyObject *
open(PyObject *self, PyObject *args)
{
char* Name;
const char* DocName=0;
if (!PyArg_ParseTuple(args, "et|s","utf-8",&Name,&DocName))
return NULL;
std::string EncodedName = std::string(Name);
PyMem_Free(Name);
PY_TRY {
QString fileName = QString::fromUtf8(EncodedName.c_str());
QFileInfo file(fileName);
// Load image from file into a QImage object
QImage imageq(fileName);
// Extract image into a general RGB format recognised by the ImageView class
int format = IB_CF_RGB24;
unsigned char *pPixelData = NULL;
if (imageq.isNull() == false) {
pPixelData = new unsigned char[3 * (unsigned long)imageq.width() * (unsigned long)imageq.height()];
unsigned char *pPix = pPixelData;
for (int r = 0; r < imageq.height(); r++) {
for (int c = 0; c < imageq.width(); c++) {
QRgb rgb = imageq.pixel(c,r);
*pPix = (unsigned char)qRed(rgb);
*(pPix + 1) = (unsigned char)qGreen(rgb);
*(pPix + 2) = (unsigned char)qBlue(rgb);
pPix += 3;
}
}
}
else
Py_Error(Base::BaseExceptionFreeCADError,"Could not load image");
// Displaying the image in a view.
// This ImageView object takes ownership of the pixel data (in 'pointImageTo') so we don't need to delete it here
ImageView* iView = new ImageView(Gui::getMainWindow());
iView->setWindowIcon( Gui::BitmapFactory().pixmap("colors") );
iView->setWindowTitle(file.fileName());
iView->resize( 400, 300 );
Gui::getMainWindow()->addWindow( iView );
iView->pointImageTo((void *)pPixelData, (unsigned long)imageq.width(), (unsigned long)imageq.height(), format, 0, true);
} PY_CATCH;
Py_Return;
}