Код: Выделить всё
int main()
CComPtr wicBitmap;
Код: Выделить всё
CComPtr stream;
WindowDevice::_IWICFactory2->CreateStream(&stream);
stream->InitializeFromFilename(_T("C:\\image.png"), GENERIC_READ);
CComPtr decoder;
WindowDevice::_IWICFactory2->CreateDecoderFromStream(stream, NULL, WICDecodeMetadataCacheOnLoad, &decoder);
CComPtr frameDecode;
decoder->GetFrame(0, &frameDecode);
CComPtr converter;
WindowDevice::_IWICFactory2->CreateFormatConverter(&converter);
converter->Initialize(
frameDecode, GUID_WICPixelFormat32bppPBGRA, WICBitmapDitherTypeNone, NULL, 0, WICBitmapPaletteTypeCustom
);
WindowDevice::_IWICFactory2->CreateBitmapFromSource(converter, WICBitmapCacheOnLoad, &wicBitmap);
//
char** data = nullptr;
size_t* dataSize = 0;
D2D1_SIZE_U bitmapSize = { };
wicBitmap->GetSize(&bitmapSize.width, &bitmapSize.height);
WICRect rcLock = { 0, 0, bitmapSize.width, bitmapSize.height };
CComPtr lock;
wicBitmap->Lock(&rcLock, WICBitmapLockRead, &lock);
UINT tempBitmapSize = 0;
unsigned char* tempData = nullptr;
lock->GetDataPointer(&tempBitmapSize, &tempData);// data = '\0'
return 0;
Подробнее здесь: https://stackoverflow.com/questions/791 ... itmap-is-0