0

I'm get through c++ invoke(...) method result at type VARIANT * var. var is .bmp image.

qDebug() << var.vt; //8209 ~ VT_ARRAY|VT_UI1 ~ SAFEARRAY(BYTE)

How convert it from SAFEARRAY(BYTE) to QByteArray? Or how get QImage (QPixmap, QBitmap)? Thanks/.

magrif
  • 396
  • 4
  • 20
  • There is no conversion, you'll have to create a new QByteArray and copy the elements. – Hans Passant Nov 22 '15 at 17:43
  • 4
    The `SAFEARRAY*` pointer is in `var.parray`. Use `SafeArrayGetLBound` and `SafeArrayGetUBound` to determine its size (remember that bounds are inclusive; the size is `ubound-lbound+1`), and `SafeArrayAccessData` to get a pointer to raw data. Wrap it in `QByteArray` with `QByteArray::fromRawData`. Make sure to `SafeArrayUnaccessData` and `VariantClear` once you are done. – Igor Tandetnik Nov 23 '15 at 01:22

1 Answers1

2

Igor, great thanks!!!

long iLBound, iUBound;
char * data;
SafeArrayGetLBound(AFingerImage.parray, AFingerImage.parray->cDims, &iLBound);
SafeArrayGetUBound(AFingerImage.parray, AFingerImage.parray->cDims, &iUBound);
SafeArrayAccessData(AFingerImage.parray,(void**)(&data));
long sz = iUBound - iLBound + 1;
QByteArray ba = QByteArray::fromRawData(data,sz);
FPImage.loadFromData(ba);
SafeArrayUnaccessData(AFingerImage.parray);
magrif
  • 396
  • 4
  • 20