www.pudn.com > MyBloodVessel.rar > ximainfo.cpp
// ximainfo.cpp : main attributes
/* 03/10/2004 v1.00 - Davide Pizzolato - www.xdp.it
* CxImage version 5.99c 17/Oct/2004
*/
#include "ximage.h"
////////////////////////////////////////////////////////////////////////////////
/**
* \return the color used for transparency, and/or for background color
*/
RGBQUAD CxImage::GetTransColor()
{
if (head.biBitCount<24 && info.nBkgndIndex != -1) return GetPaletteColor((BYTE)info.nBkgndIndex);
return info.nBkgndColor;
}
////////////////////////////////////////////////////////////////////////////////
/**
* Gets the index used for transparency. Returns -1 for no transparancy.
*/
long CxImage::GetTransIndex() const
{
return info.nBkgndIndex;
}
////////////////////////////////////////////////////////////////////////////////
/**
* Sets the index used for transparency with 1, 4 and 8 bpp images. Set to -1 to remove the effect.
*/
void CxImage::SetTransIndex(long idx)
{
info.nBkgndIndex = idx;
}
////////////////////////////////////////////////////////////////////////////////
/**
* Sets the color used for transparency with 24 bpp images.
* You must call SetTransIndex(0) to enable the effect, SetTransIndex(-1) to disable it.
*/
void CxImage::SetTransColor(RGBQUAD rgb)
{
rgb.rgbReserved=0;
info.nBkgndColor = rgb;
}
////////////////////////////////////////////////////////////////////////////////
bool CxImage::IsTransparent() const
{
return info.nBkgndIndex>=0; //
}
////////////////////////////////////////////////////////////////////////////////
/**
* Returns true if the image has 256 colors or less.
*/
bool CxImage::IsIndexed() const
{
return head.biClrUsed!=0;
}
////////////////////////////////////////////////////////////////////////////////
/**
* \return 1 = indexed, 2 = RGB, 4 = RGBA
*/
BYTE CxImage::GetColorType()
{
BYTE b = (BYTE)((head.biBitCount>8) ? 2 /*COLORTYPE_COLOR*/ : 1 /*COLORTYPE_PALETTE*/);
#if CXIMAGE_SUPPORT_ALPHA
if (AlphaIsValid()) b = 4 /*COLORTYPE_ALPHA*/;
#endif //CXIMAGE_SUPPORT_ALPHA
return b;
}
////////////////////////////////////////////////////////////////////////////////
/**
* \return Resolution for TIFF, JPEG, PNG and BMP formats.
*/
long CxImage::GetXDPI() const
{
return info.xDPI;
}
////////////////////////////////////////////////////////////////////////////////
/**
* \return Resolution for TIFF, JPEG, PNG and BMP formats.
*/
long CxImage::GetYDPI() const
{
return info.yDPI;
}
////////////////////////////////////////////////////////////////////////////////
/**
* Set resolution for TIFF, JPEG, PNG and BMP formats.
*/
void CxImage::SetXDPI(long dpi)
{
if (dpi<=0) dpi=96;
info.xDPI = dpi;
head.biXPelsPerMeter = (long) floor(dpi * 10000.0 / 254.0 + 0.5);
}
////////////////////////////////////////////////////////////////////////////////
/**
* Set resolution for TIFF, JPEG, PNG and BMP formats.
*/
void CxImage::SetYDPI(long dpi)
{
if (dpi<=0) dpi=96;
info.yDPI = dpi;
head.biYPelsPerMeter = (long) floor(dpi * 10000.0 / 254.0 + 0.5);
}
////////////////////////////////////////////////////////////////////////////////
/**
* \sa SetFlags
*/
DWORD CxImage::GetFlags() const
{
return info.dwFlags;
}
////////////////////////////////////////////////////////////////////////////////
/**
* Image flags, for future use
* \param flags
* - 0x??00000 = reserved for 16 bit, CMYK, multilayer
* - 0x00??0000 = blend modes
* - 0x0000???? = layer id or user flags
*
* \param bLockReservedFlags protects the "reserved" and "blend modes" flags
*/
void CxImage::SetFlags(DWORD flags, bool bLockReservedFlags)
{
if (bLockReservedFlags) info.dwFlags = flags & 0x0000ffff;
else info.dwFlags = flags;
}
////////////////////////////////////////////////////////////////////////////////
/**
* \sa SetCodecOption
*/
DWORD CxImage::GetCodecOption(DWORD imagetype)
{
if (imagetype