Direct2D怎样读取加密jpg?
比方说,我有一个test.jpg,我把test.jpg的每个字节+=1,然后生成test.dat,请问direct2d应该怎么读取那个test.dat然后用WIC来解码绘制bitmap
程序代码:
void dx::loadFromMem() { using namespace std; fstream file; file.open("test.dat", ios::binary | ios::in); file.seekp(0, ios::end); int length = file.tellp(); file.seekp(0, ios::beg); byte* x = NULL; x = new byte[length]; memset(x, 0, length); for (int i = 0; i < length; i++) { x[i] = file.get()-1; } file.close(); IWICStream* file2=NULL; IWICBitmapDecoder* bitmapdecoder = NULL; imageFactory->CreateStream(&file2); file2->InitializeFromMemory(x, length); if (S_OK != imageFactory->CreateDecoderFromStream(file2, NULL, WICDecodeMetadataCacheOnLoad, &bitmapdecoder)) { MessageBox(NULL, L"Create Decoder Fail", L"cant open 2.jpg", MB_OK); exit(-1); } IWICBitmapFrameDecode* pframe = NULL; bitmapdecoder->GetFrame(0, &pframe); IWICFormatConverter* fmtcovter = NULL; imageFactory->CreateFormatConverter(&fmtcovter); fmtcovter->Initialize(pframe, GUID_WICPixelFormat32bppPBGRA, WICBitmapDitherTypeNone, NULL, 0.0f, WICBitmapPaletteTypeCustom); renderTarget->CreateBitmapFromWicBitmap(fmtcovter, NULL, &bitmap); fmtcovter->Release(); pframe->Release(); bitmapdecoder->Release(); }
[此贴子已经被作者于2021-5-31 18:13编辑过]