本文整理汇总了C++中gdiplus::Image::GetHorizontalResolution方法的典型用法代码示例。如果您正苦于以下问题:C++ Image::GetHorizontalResolution方法的具体用法?C++ Image::GetHorizontalResolution怎么用?C++ Image::GetHorizontalResolution使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gdiplus::Image
的用法示例。
在下文中一共展示了Image::GetHorizontalResolution方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: assert
static Image *ReadEMFImage(const ImageInfo *image_info,
ExceptionInfo *exception)
{
Gdiplus::Bitmap
*bitmap;
Gdiplus::BitmapData
bitmap_data;
Gdiplus::GdiplusStartupInput
startup_input;
Gdiplus::Graphics
*graphics;
Gdiplus::Image
*source;
Gdiplus::Rect
rect;
GeometryInfo
geometry_info;
Image
*image;
MagickStatusType
flags;
register Quantum
*q;
register ssize_t
x;
ssize_t
y;
ULONG_PTR
token;
unsigned char
*p;
wchar_t
fileName[MagickPathExtent];
assert(image_info != (const ImageInfo *) NULL);
assert(image_info->signature == MagickSignature);
if (image_info->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
image_info->filename);
assert(exception != (ExceptionInfo *) NULL);
image=AcquireImage(image_info,exception);
if (Gdiplus::GdiplusStartup(&token,&startup_input,NULL) !=
Gdiplus::Status::Ok)
ThrowReaderException(CoderError, "GdiplusStartupFailed");
MultiByteToWideChar(CP_UTF8,0,image->filename,-1,fileName,MagickPathExtent);
source=Gdiplus::Image::FromFile(fileName);
if (source == (Gdiplus::Image *) NULL)
{
Gdiplus::GdiplusShutdown(token);
ThrowReaderException(FileOpenError,"UnableToOpenFile");
}
image->resolution.x=source->GetHorizontalResolution();
image->resolution.y=source->GetVerticalResolution();
image->columns=(size_t) source->GetWidth();
image->rows=(size_t) source->GetHeight();
if (image_info->density != (char *) NULL)
{
flags=ParseGeometry(image_info->density,&geometry_info);
image->resolution.x=geometry_info.rho;
image->resolution.y=geometry_info.sigma;
if ((flags & SigmaValue) == 0)
image->resolution.y=image->resolution.x;
if ((image->resolution.x > 0.0) && (image->resolution.y > 0.0))
{
image->columns=(size_t) floor((Gdiplus::REAL) source->GetWidth() /
source->GetHorizontalResolution() * image->resolution.x + 0.5);
image->rows=(size_t)floor((Gdiplus::REAL) source->GetHeight() /
source->GetVerticalResolution() * image->resolution.y + 0.5);
}
}
bitmap=new Gdiplus::Bitmap((INT) image->columns,(INT) image->rows,
PixelFormat32bppARGB);
graphics=Gdiplus::Graphics::FromImage(bitmap);
graphics->SetInterpolationMode(Gdiplus::InterpolationModeHighQualityBicubic);
graphics->SetSmoothingMode(Gdiplus::SmoothingModeHighQuality);
graphics->SetTextRenderingHint(Gdiplus::TextRenderingHintClearTypeGridFit);
graphics->Clear(Gdiplus::Color((BYTE) ScaleQuantumToChar(
image->background_color.alpha),(BYTE) ScaleQuantumToChar(
image->background_color.red),(BYTE) ScaleQuantumToChar(
image->background_color.green),(BYTE) ScaleQuantumToChar(
image->background_color.blue)));
graphics->DrawImage(source,0,0,(INT) image->columns,(INT) image->rows);
delete graphics;
//.........这里部分代码省略.........
示例2: scaledImage
int DrawSdk::Image::WriteScaledImageFile(WCHAR* scaledImageName, float scaleX, float scaleY, const WCHAR* format)
{
int hr = S_OK;
// // Starting the Gdiplus machine should be executed outside of this method
// Gdiplus::GdiplusStartupInput gdiplusStartupInput;
// ULONG_PTR gdiplusToken;
// Gdiplus::GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
Gdiplus::ImageCodecInfo *pImageCodecInfo = NULL;
CLSID *pClsid = NULL;
HDC hdc = CreateCompatibleDC(NULL);
// Get the encoder CLSID depending on the image format (image/jpeg, image/gif, image/png)
UINT num = 0;
UINT size = 0;
Gdiplus::GetImageEncodersSize(&num, &size);
if (size == 0)
hr = -1; // Failure
if (SUCCEEDED(hr))
{
pImageCodecInfo = (Gdiplus::ImageCodecInfo*)(malloc(size));
if (pImageCodecInfo == NULL)
hr = -1; // Failure
}
if (SUCCEEDED(hr))
{
Gdiplus::GetImageEncoders(num, size, pImageCodecInfo);
for(int j = 0; j < num; ++j)
{
if( wcscmp(pImageCodecInfo[j].MimeType, format) == 0 )
{
pClsid = &pImageCodecInfo[j].Clsid;
break; // Success
}
}
if (pClsid == NULL)
hr = -1; // Failure
}
// Bugfix 5301:
// If 'gdipImage_' is NULL then it was not kept in memory and therefore
// a temporary Gdiplus::Image object is created for the rescaling.
// This avoids having too much image data in the memory.
Gdiplus::Image *tmpImage = NULL;
if (SUCCEEDED(hr) && gdipImage_ == NULL) {
// convert char-String in WCHAR-String
int iStringLength = _tcslen(imageName_) + 1;
WCHAR *wcFilename = (WCHAR *)malloc(iStringLength*sizeof(WCHAR));
#ifdef _UNICODE
wcscpy(wcFilename, imageName_);
#else
MultiByteToWideChar( CP_ACP, 0, imageName, iStringLength,
wcFilename, iStringLength);
#endif
tmpImage = new Gdiplus::Image(wcFilename, FALSE);
if (wcFilename)
free(wcFilename);
} else {
tmpImage = gdipImage_;
}
if (SUCCEEDED(hr) && tmpImage != NULL)
{
// Resize the image by scaling factors
Gdiplus::REAL destWidth = scaleX * this->GetWidth();
Gdiplus::REAL destHeight = scaleY * this->GetHeight();
// If no correct size is defined in the object queue, use the real image size instead
if ( (this->GetWidth() <= 0.0f) && (this->GetHeight() <= 0.0f) )
{
destWidth = scaleX * tmpImage->GetWidth();
destHeight = scaleY * tmpImage->GetHeight();
}
// At least we have to write one pixel
if (destWidth < 1.0f)
destWidth = 1.0f;
if (destHeight < 1.0f)
destHeight = 1.0f;
Gdiplus::Bitmap scaledImage((int)(destWidth + 0.5f), (int)(destHeight + 0.5f));
scaledImage.SetResolution(tmpImage->GetHorizontalResolution(),
tmpImage->GetVerticalResolution());
Gdiplus::Graphics grPhoto(&scaledImage);
grPhoto.SetCompositingQuality(Gdiplus::CompositingQualityHighSpeed);
grPhoto.SetCompositingMode(Gdiplus::CompositingModeSourceOver);
//.........这里部分代码省略.........