VPictureData_MacPicture::VPictureData_MacPicture(xMacPictureHandle inMacPicHandle) :VPictureData_Vector() { _SetDecoderByExtension(sCodec_pict); fDataSourceDirty = true; fDataSourceMetadatasDirty = true; fPicHandle = NULL; fMetaFile = NULL; fTrans = NULL; #if VERSIONWIN fGdiplusMetaFile = 0; #endif if (inMacPicHandle) { #if VERSIONWIN // pp c'est une resource, sous windows elle est deja swapé ByteSwapWordArray((sWORD*) (*inMacPicHandle), 5); #endif VPictureDataProvider *prov = VPictureDataProvider::Create((xMacHandle) inMacPicHandle, false); #if VERSIONWIN // pp c'est une resource, sous windows elle est deja swapé ByteSwapWordArray((sWORD*) (*inMacPicHandle), 5); #endif if (prov) { prov->SetDecoder(fDecoder); SetDataProvider(prov, true); prov->Release(); } } }
void* VPictureData_MacPicture::_BuildPicHandle()const { void* outPicHandle = NULL; VIndex offset = 0; if (GetMacAllocator() && fDataProvider && fDataProvider->GetDataSize()) { if (fDataProvider->IsFile()) { outPicHandle = GetMacAllocator()->Allocate(fDataProvider->GetDataSize() - 0x200); offset = 0x200; } else outPicHandle = GetMacAllocator()->Allocate(fDataProvider->GetDataSize()); } if (outPicHandle) { VSize datasize = fDataProvider->GetDataSize(); if (fDataProvider->IsFile()) { datasize -= 0x200; } GetMacAllocator()->Lock(outPicHandle); fDataProvider->GetData(*(char**) outPicHandle, offset, datasize); #if VERSIONWIN ByteSwapWordArray(*(sWORD**) outPicHandle, 5); #endif GetMacAllocator()->Unlock(outPicHandle); } return outPicHandle; }
xMacPictureHandle VPictureData_EMF::GetPicHandle()const { if(!fPicHandle) { if(fDataProvider && fDataProvider->GetDataSize()) fPicHandle=GetMacAllocator()->Allocate(fDataProvider->GetDataSize()); if(fPicHandle) { //VPtr p=fDataProvider->BeginDirectAccess(); GetMacAllocator()->Lock(fPicHandle); fDataProvider->GetData(*(char**)fPicHandle,0,fDataProvider->GetDataSize()); //CopyBlock(p,*(char**)fPicHandle,fDataProvider->GetDataSize()); #if VERSIONWIN ByteSwapWordArray(*(sWORD**)fPicHandle,5); #endif GetMacAllocator()->Unlock(fPicHandle); //fDataProvider->EndDirectA(); } } if(fPicHandle) { assert(GetMacAllocator()->CheckBlock(fPicHandle)); } return (xMacPictureHandle)fPicHandle; }
VError VPictureData_MacPicture::Save(VBlob* inData, VIndex inOffset, VSize& outSize, _VPictureAccumulator* inRecorder)const { VError result = VE_OK; VSize headersize = 0; if (fDataProvider) { if (fDataProvider->IsFile()) { if (inData->IsOutsidePath()) { result = inherited::Save(inData, inOffset, outSize, inRecorder); } else { assert(fDataProvider->GetDataSize()>0x200); VPtr dataptr = fDataProvider->BeginDirectAccess(); if (dataptr) { dataptr += 0x200; result = inData->PutData(dataptr, fDataProvider->GetDataSize() - 0x200, inOffset); fDataProvider->EndDirectAccess(); } else fDataProvider->GetLastError(); } } else { if (inData->IsOutsidePath()) { char buff[0x200]; headersize = 0x200; memset(buff, 0, headersize); result = inData->PutData(buff, headersize, inOffset); inOffset += headersize; inherited::Save(inData, inOffset, outSize, inRecorder); outSize += headersize; } else { result = inherited::Save(inData, inOffset, outSize, inRecorder); } } } else { if (GetMacAllocator()) { if (fPicHandle) { GetMacAllocator()->Lock(fPicHandle); VPtr p = *(char**) fPicHandle; if (p) { outSize = GetMacAllocator()->GetSize(fPicHandle); if (inData->IsOutsidePath()) { char buff[0x200]; headersize = 0x200; memset(buff, 0, headersize); result = inData->PutData(buff, headersize, inOffset); inOffset += headersize; } #if VERSIONWIN ByteSwapWordArray((sWORD*) p, 5); #endif result = inData->PutData(p, outSize, inOffset); #if VERSIONWIN ByteSwapWordArray((sWORD*) p, 5); #endif outSize += headersize; } GetMacAllocator()->Unlock(fPicHandle); } } else result = VE_UNIMPLEMENTED; } return result; }