本文整理汇总了C++中gdiplus::Bitmap::RotateFlip方法的典型用法代码示例。如果您正苦于以下问题:C++ Bitmap::RotateFlip方法的具体用法?C++ Bitmap::RotateFlip怎么用?C++ Bitmap::RotateFlip使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gdiplus::Bitmap
的用法示例。
在下文中一共展示了Bitmap::RotateFlip方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initWithEncodedData
bool VisualTextureContainer::initWithEncodedData(const char* const bufferData, size_t size) {
bool success = true;
bool debug = false;
this->releaseTextureData();
uint32* aPixelBuffer = NULL;
#if TARGET_OS_WIN
HGLOBAL hGlobal = ::GlobalAlloc(GMEM_MOVEABLE | GMEM_NODISCARD, (SIZE_T)size);
if (!hGlobal)
return false;
BYTE* pDest = (BYTE*)::GlobalLock(hGlobal);
memcpy(pDest, bufferData, size);
::GlobalUnlock(hGlobal);
IStream* pStream = NULL;
if (::CreateStreamOnHGlobal(hGlobal, FALSE, &pStream) != S_OK)
return false;
Gdiplus::Bitmap* bitmap = Gdiplus::Bitmap::FromStream(pStream);
bitmap->RotateFlip(Gdiplus::RotateNoneFlipY);
this->imageRect.width = bitmap->GetWidth();
this->imageRect.height = bitmap->GetHeight();
VisualGraphics* theVisualGraphics = VisualGraphics::getInstance();
this->useRectExtension = theVisualGraphics->canUseTextureRectExtension();
if (this->useRectExtension == false) {
this->textureRect.width = theVisualGraphics->power2Ceiling(this->imageRect.width);
this->textureRect.height = theVisualGraphics->power2Ceiling(this->imageRect.height);
} else {
this->textureRect.width = this->imageRect.width;
this->textureRect.height = this->imageRect.height;
}
aPixelBuffer = (uint32*)malloc(this->imageRect.width * this->imageRect.height * sizeof(uint32));
Gdiplus::Rect rect(0, 0, this->imageRect.width, this->imageRect.height);
Gdiplus::BitmapData* bitmapData = new Gdiplus::BitmapData;
bitmapData->Width = this->imageRect.width;
bitmapData->Height = this->imageRect.height;
bitmapData->Stride = sizeof(uint32) * bitmapData->Width;
bitmapData->PixelFormat = PixelFormat32bppARGB;
bitmapData->Scan0 = (VOID*)aPixelBuffer;
Gdiplus::Status status = Gdiplus::Ok;
status = bitmap->LockBits(&rect, Gdiplus::ImageLockModeRead | Gdiplus::ImageLockModeUserInputBuf, PixelFormat32bppPARGB, bitmapData);
#endif
#if TARGET_OS_MAC
CFDataRef dataRef = CFDataCreateWithBytesNoCopy(kCFAllocatorDefault, (UInt8*)bufferData, (CFIndex)size, kCFAllocatorDefault);
CFDictionaryRef options = NULL;
CGImageSourceRef imageSourceRef = CGImageSourceCreateWithData(dataRef, options);
CGImageRef imageRef = CGImageSourceCreateImageAtIndex(imageSourceRef, 0, options);
this->imageRect.width = CGImageGetWidth(imageRef);
this->imageRect.height = CGImageGetHeight(imageRef);
VisualGraphics* theVisualGraphics = VisualGraphics::getInstance();
this->useRectExtension = theVisualGraphics->canUseTextureRectExtension();
if (this->useRectExtension == false) {
this->textureRect.width = theVisualGraphics->power2Ceiling(this->imageRect.width);
this->textureRect.height = theVisualGraphics->power2Ceiling(this->imageRect.height);
} else {
this->textureRect.width = this->imageRect.width;
this->textureRect.height = this->imageRect.height;
}
CGContextRef contextPtr = theVisualGraphics->createBitmapContext(this->imageRect.width, this->imageRect.height);
CGContextTranslateCTM(contextPtr, 0, this->imageRect.height);
CGContextScaleCTM(contextPtr, 1.0f, -1.0f);
CGRect rect = CGRectMake(0, 0, this->imageRect.width, this->imageRect.height);
CGContextDrawImage(contextPtr, rect, imageRef);
aPixelBuffer = static_cast<uint32*>(CGBitmapContextGetData(contextPtr));
#endif
PixelColor* interleavedARGBColorPixelBuffer = NULL;
if (debug == true) {
interleavedARGBColorPixelBuffer = VisualColorTools::createARGBCheckPixels(this->textureRect.width, this->textureRect.height);
} else {
interleavedARGBColorPixelBuffer = static_cast<PixelColor*>(aPixelBuffer);
}
success = this->initWithARGBPixelData(interleavedARGBColorPixelBuffer, this->imageRect.width, this->imageRect.height);
#if TARGET_OS_MAC
CGContextRelease(contextPtr);
//.........这里部分代码省略.........