Alain Rist - Professional Profile
|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
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);
INT n = sizeOrig.cx / sizeOrig.cy,
cx = cy * n;
DRA::ImageList_StretchBitmap(bmpOrig, &bmp.m_hBitmap, cx, cy, n, 1);
iml.Create(cx, cy, uFlags, n, 0);
iml.Add(bmp.IsNull() ? bmpOrig : bmp);
::SHLoadImageResource() loads the PNG as a 16bits DIB (native DDB format), so alpha is lost before the call to
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.
modified on Saturday, April 25, 2009 5:26 AM
General News Suggestion Question Bug Answer Joke Praise Rant Admin
Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.