Jump to content
View in the app

A better way to browse. Learn more.

Tuts 4 You

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

How to write ImageList?

Featured Replies

Posted

I use ImageList_Write to save imagelist, but the saved bmp is

not really bitmap format! But I can display the ImageList correctly in my app.

Any buddy could help me? Thanks a lot.

Attachment is my project.

//code////////////////////////////////////////////////////////////////

HDC hdc;

PAINTSTRUCT ps;

static HIMAGELIST hil;

HICON hicon1, hicon2, hicon3;

int i;

IStream * pStream;

case WM_CREATE:

pStream = 0;
hil = ImageList_Create(16, 16, ILC_COLORDDB, 3, 0);
ImageList_SetBkColor(hil, RGB(255,255,255));
hicon1 = LoadIcon(hInst, "MYICON1");
ImageList_AddIcon(hil, hicon1);
hicon2 = LoadIcon(hInst, "MYICON2");
ImageList_AddIcon(hil, hicon2);
hicon3 = LoadIcon(hInst, "MYICON3");
ImageList_AddIcon(hil, hicon3);
SHCreateStreamOnFile("o.bmp", STGM_READWRITE | STGM_CREATE, &pStream);
if(ImageList_Write(hil, pStream)) {
MessageBox(0, "write successfully", "", 0);
}
pStream->Release();

imglist.zip

Edited by alaphate

Gday mate.

Remember that an imagelist is a list, or collection of icons. Icons are themselves a special case of bitmaps.

In order to write the imagelist to ordinary bitmaps, a number of descisions need to be made. Among these:

(1) Will you write individual files or will you stitch them all together and save a single file

(2) Will you preserve the transparency of the image

What you need to do is:

  • extract the icon from the imageList
  • get the icon's info (pointer to colour and mask bitmaps, etc)
  • get the app window's hdc
  • create a hdc compatible with this
  • select the icon's color bitmap into this 2nd hdc
  • Save the hdc to a Bitmap file
  • Perform any necessary clean-up

If you don't create a compatibleDC from the app's DC, the image you get is simply a screen-shot of your desk-top. Though strangely, my #2 screen is on the left of my #1 screen - the weird part is that the screen-shot contains the image of screen 1 on the left of the bitmap, yet contains nothing from screen 2 - oh, and it's a 9MB bitmap too. :geek:

I've been playing with this for the past couple of days, and have some code for you that will save any image in an imagelist to a file on it's own. It doesn't respect the transparency of the initial icon, though it's too late for my little brain right now (3am).

Anyway, here y'are - code's often better than idle chit-chat.

imglist.zip

  • Author

enhzflep,

Thank you for your great work.

I know there's a way to save the imagelist by drawing imagelist

into a bitmap in memory DC, and saving it.

Another problem is how to use SHCreateStreamOnFile function

to save it. IStream class seems complicated for me.

I'd like to learn how to use it.

Are there any examples or tutorials for it?

I appreciate your help very much.

Create an account or sign in to comment

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.