本文整理汇总了C++中JXColormap::GetVisual方法的典型用法代码示例。如果您正苦于以下问题:C++ JXColormap::GetVisual方法的具体用法?C++ JXColormap::GetVisual怎么用?C++ JXColormap::GetVisual使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JXColormap
的用法示例。
在下文中一共展示了JXColormap::GetVisual方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: JAccessDenied
JError
JXImage::CreateFromXPM
(
JXDisplay* display,
const JCharacter* fileName,
JXImage** image
)
{
#ifdef _J_HAS_XPM
JXColormap* colormap = display->GetColormap();
Pixmap image_pixmap = None;
Pixmap mask_pixmap = None;
XpmAttributes attr;
attr.valuemask = XpmVisual | XpmColormap | XpmDepth |
XpmExactColors | XpmCloseness |
XpmColorKey | XpmAllocCloseColors |
XpmReturnAllocPixels;
attr.visual = colormap->GetVisual();
attr.colormap = colormap->GetXColormap();
attr.depth = display->GetDepth();
attr.color_key = XPM_COLOR;
attr.alloc_pixels = NULL;
attr.nalloc_pixels = 0;
attr.alloc_close_colors = kJTrue; // so we can free all resulting pixels
attr.exactColors = 1;
attr.closeness = 0;
const int xpmErr =
XpmReadFileToPixmap(*display, display->GetRootWindow(),
const_cast<JCharacter*>(fileName),
&image_pixmap, &mask_pixmap, &attr);
if (xpmErr == XpmOpenFailed && JFileExists(fileName))
{
return JAccessDenied(fileName);
}
else if (xpmErr == XpmOpenFailed)
{
return JDirEntryDoesNotExist(fileName);
}
else if (xpmErr == XpmFileInvalid)
{
return FileIsNotXPM(fileName);
}
else if (xpmErr == XpmNoMemory)
{
return JNoProcessMemory();
}
else if (xpmErr == XpmColorFailed || xpmErr == XpmColorError)
{
if (image_pixmap != None)
{
XFreePixmap(*display, image_pixmap);
}
if (mask_pixmap != None)
{
XFreePixmap(*display, mask_pixmap);
}
if (attr.alloc_pixels != NULL)
{
XFreeColors(*display, attr.colormap, attr.alloc_pixels, attr.nalloc_pixels, 0);
}
XpmFreeAttributes(&attr);
return TooManyColors();
}
// create image and mask
*image = new JXImage(display, image_pixmap);
assert( *image != NULL );
XFreePixmap(*display, image_pixmap);
if (mask_pixmap != None)
{
JXImageMask* mask = new JXImageMask(display, mask_pixmap);
assert( mask != NULL );
(**image).SetMask(mask);
XFreePixmap(*display, mask_pixmap);
}
// free pixels so X has usage count of 1
XFreeColors(*display, attr.colormap, attr.alloc_pixels, attr.nalloc_pixels, 0);
// clean up
XpmFreeAttributes(&attr);
return JNoError();
#else
return XPMNotAvailable();
#endif
}