|
On http://nativemobile.blogspot.com/[^] there is a discussion on using png images with alpha transparency on mobile devices.
This is what I use to build all the images needed at all sizes and resolutions from a single PNG resource. The PNG resource MUST be of type "GIF" to be loaded by ::SHLoadImageResource() .
Of course, requires WTL
More in my next CP Mobile article, don't ask me when .
inline HIMAGELIST AtlLoadImageList(UINT uID, int cy, UINT uFlags = ILC_COLOR32)
{
CBitmap bmpOrig = ::SHLoadImageResource(ModuleHelper::GetResourceInstance(), uID);
ATLASSERT(!bmpOrig.IsNull());
CSize sizeOrig;
bmpOrig.GetSize(sizeOrig);
INT n = sizeOrig.cx / sizeOrig.cy,
cx = cy * n;
CBitmap bmp;
DRA::ImageList_StretchBitmap(bmpOrig, &bmp.m_hBitmap, cx, cy, n, 1);
CImageList iml;
iml.Create(cx, cy, uFlags, n, 0);
iml.Add(bmp.IsNull() ? bmpOrig : bmp);
return iml;
}
Actually ::SHLoadImageResource() loads the PNG as a 16bits DIB (native DDB format), so alpha is lost before the call to DRA::ImageList_StretchBitmap() .
This is not always a problem, as all with end up as a 16bits DDB on the device graphic chip, but it may be if we need further manipulations with transparency.
Soon coming my Image component which addresses that issue.
cheers,
AR
modified on Saturday, April 25, 2009 5:26 AM
|
|
|
|