QT - Pointer to global memory
First: sorry for my English from Google
The question: I'm changing the IDE, I'm migrating from Borland to QT with QT Creator. In Borland I used a class contained in a type library (APuma.dll). The prototype was: 开发者_运维技巧 BOOL XOpen (long hDIB, LPCTSTR FileName) / / OpenOCR - Cuneiform hDIB is a pointer to global memory of an image.This version Not Work with files. To pass a pointer to global memory of an image, I used GDI+, but in QT can not find anything similar, and the inclusion of Gdiplus.h and GdiPlusInit.h generates too many errors.How do I give access to global memory where I host the image to XOpen?
Thank you very much.
OK, I think i understand what you need. You need a pointer to the pixels of the image so you can pass it. Your simplest option in Qt is using a QImage
object and using its bits()
member.
Something like this:
QImage image(filename);
uchar* p = image.bits();
XOpen(reinterpret_cast<long>(p), whatever);
just be sure that XOpen
somehow knows the dimmensions of the image. And that you have it in the right format (See QImage::convertToFormat
). For more overall information check the Qt documentation at http://doc.qt.io/qt-4.8/qimage.html
精彩评论