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; }
VPictureData_MacPicture::~VPictureData_MacPicture() { if (fPicHandle && GetMacAllocator()) { if (GetMacAllocator()->CheckBlock(fPicHandle)) GetMacAllocator()->Free(fPicHandle); } _DisposeMetaFile(); }
void VPictureData_MacPicture::_DoReset()const { _DisposeMetaFile(); if (fPicHandle && GetMacAllocator()) { GetMacAllocator()->Free(fPicHandle); fPicHandle = 0; } }
void VPictureData_MacPicture::DoDataSourceChanged() { if (fPicHandle && GetMacAllocator()) { GetMacAllocator()->Free(fPicHandle); fPicHandle = 0; } _DisposeMetaFile(); }
VSize VPictureData_MacPicture::GetDataSize(_VPictureAccumulator* /*inRecorder*/) const { if (fDataProvider) return (sLONG) fDataProvider->GetDataSize(); else if (fPicHandle && GetMacAllocator()) { return (sLONG) GetMacAllocator()->GetSize(fPicHandle); } return 0; }
VPictureData_MacPicture::VPictureData_MacPicture(const VPictureData_MacPicture& inData) :inherited(inData) { _SetDecoderByExtension(sCodec_pict); fPicHandle = NULL; fMetaFile = NULL; fTrans = NULL; #if VERSIONWIN fGdiplusMetaFile = NULL; #endif if (!fDataProvider && inData.fPicHandle && GetMacAllocator()) { fPicHandle = GetMacAllocator()->Duplicate(inData.fPicHandle); } }
VPictureData_EMF::~VPictureData_EMF() { if(fPicHandle) { GetMacAllocator()->Free(fPicHandle); } _DisposeMetaFile(); }
void VPictureData_EMF::FromMacHandle(void* inMacHandle) { _ReleaseDataProvider(); _DisposeMetaFile(); if(inMacHandle) { VSize datasize=GetMacAllocator()->GetSize(inMacHandle); if(datasize) { fPicHandle=GetMacAllocator()->Allocate(GetMacAllocator()->GetSize(inMacHandle)); if(fPicHandle) { GetMacAllocator()->Lock(fPicHandle); GetMacAllocator()->Lock(inMacHandle); CopyBlock(*(char**)inMacHandle,*(char**)fPicHandle,datasize); GetMacAllocator()->Unlock(fPicHandle); GetMacAllocator()->Unlock(inMacHandle); } } else fPicHandle=NULL; } else { fPicHandle=NULL; } }
xMacPictureHandle VPictureData_MacPicture::GetPicHandle()const { _Load(); if (fPicHandle) { assert(GetMacAllocator()->CheckBlock(fPicHandle)); } return (xMacPictureHandle) fPicHandle; }
void VPictureData_MacPicture::_DoLoad()const { if (fMetaFile) return; VIndex offset = 0; if (fDataProvider && fDataProvider->GetDataSize() && !fPicHandle) { fPicHandle = _BuildPicHandle(); } if (fPicHandle) { #if VERSIONWIN xMacRect rect; rect = (*((xMacPicture**) fPicHandle))->picFrame; //QDGetPictureBounds((qtime::Picture**)fPicHandle,&rect); fBounds.SetCoords(0, 0, rect.right - rect.left, rect.bottom - rect.top); #elif VERSIONMAC Rect rect; QDGetPictureBounds((Picture**) fPicHandle, &rect); fBounds.SetCoords(0, 0, rect.right - rect.left, rect.bottom - rect.top); #endif } if (fPicHandle) { #if VERSIONMAC GetMacAllocator()->Lock(fPicHandle); CGDataProviderRef dataprov = xV4DPicture_MemoryDataProvider::CGDataProviderCreate(*(char**) fPicHandle, GetMacAllocator()->GetSize(fPicHandle), true); GetMacAllocator()->Unlock(fPicHandle); fMetaFile = QDPictCreateWithProvider(dataprov); CGDataProviderRelease(dataprov); #elif VERSIONWIN if (sQDBridge) fMetaFile = sQDBridge->ToMetaFile(fPicHandle); #endif } }
VPictureData_EMF::VPictureData_EMF(const VPictureData_EMF& inData) :inherited(inData) { _Init(); if(!fDataProvider && inData.fPicHandle) { VSize datasize; datasize=GetMacAllocator()->GetSize(inData.fPicHandle); fPicHandle=GetMacAllocator()->Allocate(datasize); if(fPicHandle) { GetMacAllocator()->Lock(fPicHandle); GetMacAllocator()->Lock(inData.fPicHandle); CopyBlock(*(char**)inData.fPicHandle,*(char**)fPicHandle,datasize); GetMacAllocator()->Unlock(fPicHandle); GetMacAllocator()->Unlock(inData.fPicHandle); } _SetSafe(); } }
VPictureData_MacPicture::VPictureData_MacPicture(PortRef inPortRef, const VRect& inBounds) { _SetDecoderByExtension(sCodec_pict); fPicHandle = NULL; fMetaFile = NULL; fTrans = NULL; #if VERSIONWIN inPortRef; // pp pour warning inBounds; fGdiplusMetaFile = NULL; #endif #if VERSIONMAC GrafPtr oldPort; GetPort(&oldPort); SetPort(inPortRef); RGBColor saveFore, saveBack, white = { 0xffff, 0xffff, 0xffff }, black = { 0, 0, 0 }; Rect r; inBounds.MAC_ToQDRect(r); GetBackColor(&saveFore); GetForeColor(&saveFore); RGBBackColor(&white); RGBForeColor(&black); PicHandle newPicture = ::OpenPicture(&r); const BitMap* portBits = ::GetPortBitMapForCopyBits(inPortRef); ::ClipRect(&r); ::CopyBits(portBits, portBits, &r, &r, srcCopy, NULL); ::ClosePicture(); RGBBackColor(&saveFore); RGBForeColor(&saveFore); SetPort(oldPort); fPicHandle = newPicture; #if VERSIONWIN qtime::Rect rect; QDGetPictureBounds((qtime::Picture**)fPicHandle, &rect); fBounds.SetCoords(0, 0, rect.right - rect.left, rect.bottom - rect.top); #else Rect rect; QDGetPictureBounds((Picture**) fPicHandle, &rect); fBounds.SetCoords(0, 0, rect.right - rect.left, rect.bottom - rect.top); #endif #if VERSIONMAC if (fPicHandle) { GetMacAllocator()->Lock(fPicHandle); CGDataProviderRef dataprov = xV4DPicture_MemoryDataProvider::CGDataProviderCreate(*(char**) fPicHandle, GetMacAllocator()->GetSize(fPicHandle), true); GetMacAllocator()->Unlock(fPicHandle); fMetaFile = QDPictCreateWithProvider(dataprov); CGDataProviderRelease(dataprov); } #endif #endif }
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; }