Discussion:
ImageList_GetImageInfo - alter the bitmap(s) ?
(too old to reply)
R.Wieser
2024-09-30 19:11:50 UTC
Permalink
Hello all,

Using XPsp3.

I was playing with the idea to dynamically alter the contents of an
ImageList, and found the
https://learn.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-imagelist_getimageinfo
function, which says :

"The information in this structure can be used to *directly* manipulate the
bitmaps for the image"

(bolding mine).

I've been trying to think of how that is possible - the bitmaps cannot be
selected into a memoryDC - and to google information about how that would
work, but came up empty.

Question:
Does anyone know what "directly manipulate the bitmaps" method MS is
referring to in the above ?

Remark:
I already thought of and written another way to do what I want, but would
like to know how the above works. Who knows, their (MS) method might be
simpler. :-)

Regards,
Rudy Wieser
Newyana2
2024-09-30 19:41:57 UTC
Permalink
Post by R.Wieser
Hello all,
Using XPsp3.
I was playing with the idea to dynamically alter the contents of an
ImageList, and found the
https://learn.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-imagelist_getimageinfo
"The information in this structure can be used to *directly* manipulate the
bitmaps for the image"
(bolding mine).
I've been trying to think of how that is possible - the bitmaps cannot be
selected into a memoryDC - and to google information about how that would
work, but came up empty.
Does anyone know what "directly manipulate the bitmaps" method MS is
referring to in the above ?
I already thought of and written another way to do what I want, but would
like to know how the above works. Who knows, their (MS) method might be
simpler. :-)
I've never used an ImageList, but the docs say GetImageInfo returns
an ImageInfo structure, which includes an hBitmap. With that you can
call things like GetDIBits, SetDIBits, etc.
R.Wieser
2024-10-01 07:02:57 UTC
Permalink
Newyana2,
but the docs say GetImageInfo returns an ImageInfo structure, which
includes an hBitmap.
Indeed it does. Having the bitmap(s) is where my problems started. :-\
With that you can call things like GetDIBits, SetDIBits, etc.
Yep, I found the first one too (as well as GetBitmapBits). But I realized
that it takes a *lot* of work to be able to create something generic from it
(for instance, it would need handlers for all 6 BPP modi).

Also SetDIBits needs a BITMAPINFO structure filled in with stuff I /somehow/
would need to extract/copy from the origional bitmap.

The easier way (I think) would be to use CopyBitmap, load it into a
memoryDC* and use that to make the alterations on.

* which I would need to make sure it would have the same configuration
(Image List Creation Flags) as the one the ImageList was created with. In
short: another problem.

... but that than has a "how do I get it back into the origional
bitmap/imagelist ?" problem.

I was hoping that the MS way would show me a simple, smart way to circumvent
all that clumsy work.

By the way:
for one test approach I invoked "the dark arts" and retrieved the
memoryDC(s) the ImageList uses internally. Drawing on them works as
expected, very easy. Though there are a number of gotya's to recon with. As
well as the use of "the dark arts" ofcourse. :-)

Regards,
Rudy Wieser
Newyana2
2024-10-01 14:37:57 UTC
Permalink
Post by R.Wieser
Newyana2,
but the docs say GetImageInfo returns an ImageInfo structure, which
includes an hBitmap.
Indeed it does. Having the bitmap(s) is where my problems started. :-\
With that you can call things like GetDIBits, SetDIBits, etc.
Yep, I found the first one too (as well as GetBitmapBits). But I realized
that it takes a *lot* of work to be able to create something generic from it
(for instance, it would need handlers for all 6 BPP modi).
Also SetDIBits needs a BITMAPINFO structure filled in with stuff I /somehow/
would need to extract/copy from the origional bitmap.
The easier way (I think) would be to use CopyBitmap, load it into a
memoryDC* and use that to make the alterations on.
* which I would need to make sure it would have the same configuration
(Image List Creation Flags) as the one the ImageList was created with. In
short: another problem.
... but that than has a "how do I get it back into the origional
bitmap/imagelist ?" problem.
I was hoping that the MS way would show me a simple, smart way to circumvent
all that clumsy work.
for one test approach I invoked "the dark arts" and retrieved the
memoryDC(s) the ImageList uses internally. Drawing on them works as
expected, very easy. Though there are a number of gotya's to recon with. As
well as the use of "the dark arts" ofcourse. :-)
That stuff is something I have to figure out anew every time I
work with it. I once wrote a program for my girlfriend to easily
do auto-cropping and resizing of photos in high quality. The image
ops were so complicated that I used a class to load images, convert
to DIB, then do operations on that. GDI gets very complicated.
Gdiplus is worse.

Recently I've been working on functionality to change caret width
and color in a text window. The way to do it is to use a bitmap. So
I needed to be able to generate an endless variety of bitmaps
"on the fly". It took awhile to refresh my memory about hbitmaps and
DCs and such. But in VB6 there's the Picturebox control. Lightweight
and it wraps a lot of GDI ops. It turned out that I could paint the caret
in a hidden picturebox, then pass that picture's handle to the caret
function because a picture in a picturebox is a StdPicture. Maybe you
have something like that with Borland?

In terms of imaglists, I have no idea. I've never had occasion to
use one. I sometimes use Image controls and sometimes use resources,
but never an imagelist.
R.Wieser
2024-10-01 17:11:02 UTC
Permalink
Newyana2,
GDI gets very complicated. Gdiplus is worse.
I've used both, but have not tried anything complicated with it.
Recently I've been working on functionality to change caret width
and color in a text window. The way to do it is to use a bitmap.
That makes me remember something ..Oh yes, there it is. Maybe its useful to
you :

https://devblogs.microsoft.com/oldnewthing/20240916-00/?p=110272
But in VB6 there's the Picturebox control. Lightweight
and it wraps a lot of GDI ops.
...
Maybe you have something like that with Borland?
:-) Thats the nice thing of using an Assembler : No programming-language
provided wrappers around anything, you have to (understand and) write all of
them yourself.

... which is also its downside.

But with me being me I normally have little problem with that. Even though
that leads to problems as my current one.
I sometimes use Image controls and sometimes use resources,
but never an imagelist.
If you have ever used a List- or TreeView showing icons (including
sorting-direction arrows and tickboxes) than you have used an ImageList.

Regards,
Rudy Wieser
Newyana2
2024-10-02 00:12:25 UTC
Permalink
Post by R.Wieser
That makes me remember something ..Oh yes, there it is. Maybe its useful to
https://devblogs.microsoft.com/oldnewthing/20240916-00/?p=110272
Even Raymond Chen has opted for totally fucked up web design.
His page is pure white for me unless I disable CSS. He must be tryint
to force script.
Post by R.Wieser
If you have ever used a List- or TreeView showing icons (including
sorting-direction arrows and tickboxes) than you have used an ImageList.
Nope. I've never needed those and they seem like a pain.
R.Wieser
2024-10-02 07:08:40 UTC
Permalink
Newyana2,
Post by Newyana2
Even Raymond Chen has opted for totally fucked up web design.
His page is pure white for me unless I disable CSS.
Ah yes, I forgot about that. I scrubbed that page (like many others) using
GreaseMonkey. A quite handy add-on.
Post by Newyana2
He must be tryint to force script.
He ? devblogs.microsoft.com isn't his private domain you know. :-)

But yes, JS could have something to do with it - as I have disabled it too.
Post by Newyana2
Post by R.Wieser
If you have ever used a List- or TreeView showing icons (including
sorting-direction arrows and tickboxes) than you have used an ImageList.
Nope. I've never needed those and they seem like a pain.
List- and/or TreeViews, or images in them ?

I can't say I've used TreeViews much, but have used ListViews a number of
times, and some of them with ImageLists.

Images in in either a List- or TreeView is easier than you might think.
Just create an ImageList and assign it to the View, load some images/icons
into it, and tell, when adding an entry into either View, which image you
want to display. Thats all there is to it.

But yes, it took me a while until I had/have everything figured out. Thats
what happens when most of what you find is "learn.microsoft.com" pages
(which mostly do not /learn/ you anything, but are "what again where the
arguments to that function?" reference pages - and often incomplete. As the
one I started this thread with) and the odd bits-and-pieces of "example"
code I can find on the Web.

Regards,
Rudy Wieser
Kerr-Mudd, John
2024-10-02 16:07:34 UTC
Permalink
On Tue, 1 Oct 2024 19:11:02 +0200
Post by R.Wieser
Newyana2,
GDI gets very complicated. Gdiplus is worse.
I've used both, but have not tried anything complicated with it.
Recently I've been working on functionality to change caret width
and color in a text window. The way to do it is to use a bitmap.
That makes me remember something ..Oh yes, there it is. Maybe its useful to
https://devblogs.microsoft.com/oldnewthing/20240916-00/?p=110272
But in VB6 there's the Picturebox control. Lightweight
and it wraps a lot of GDI ops.
...
Maybe you have something like that with Borland?
:-) Thats the nice thing of using an Assembler : No programming-language
provided wrappers around anything, you have to (understand and) write all of
them yourself.
Unless you use libraries aznd function calls extensively.
Post by R.Wieser
... which is also its downside.
But with me being me I normally have little problem with that. Even though
that leads to problems as my current one.
I sometimes use Image controls and sometimes use resources,
but never an imagelist.
If you have ever used a List- or TreeView showing icons (including
sorting-direction arrows and tickboxes) than you have used an ImageList.
Regards,
Rudy Wieser
--
Bah, and indeed Humbug.
R.Wieser
2024-10-02 16:55:41 UTC
Permalink
John,
Post by Kerr-Mudd, John
No programming-language provided wrappers around anything,
you have to (understand and) write all of them yourself.
Unless you use libraries aznd function calls extensively.
And thats indeed what I do. :-)

I *have* to, as, as mentioned, my programming language of choice, Assembly
(Borlands Tasm32), doesn't offer such wrappers.

Regards,
Rudy Wieser
Newyana2
2024-10-02 17:28:17 UTC
Permalink
Post by R.Wieser
John,
Post by Kerr-Mudd, John
No programming-language provided wrappers around anything,
you have to (understand and) write all of them yourself.
Unless you use libraries aznd function calls extensively.
And thats indeed what I do. :-)
I *have* to, as, as mentioned, my programming language of choice, Assembly
(Borlands Tasm32), doesn't offer such wrappers.
I bought the assembly bible once and started reading. I decided
life's too short for that. The beauty of VB6 is that I can drag-drop
GUI elements. No 3 pages of code to create a button. At the same
time, I can use Win32 API for most of the functionality. I probably
never would have bothered if the only choice were early C++. If I
want to write that doesn't mean I also want to perfect paper
manufacturing. I can see the appeal of building a ship in a
bottle. I'm just too practical to do all that work only to have an
object to sit on a bookshelf.
R.Wieser
2024-10-02 19:47:52 UTC
Permalink
Newyana2,
Post by Newyana2
I bought the assembly bible once and started reading. I decided
life's too short for that.
:-)

I pretty-much started with Assembly and worked my way thru a number of home
computers (TRS80, Apple 2e, commodore 64) to arrive at the X86 machines,
starting with DOS 3.3, where I started to use borlands assembler(s). Later
on I bought Borlands Tasm32

Although I've tried a few other programming languages, somehow I always
returned to Assembly.
Post by Newyana2
The beauty of VB6 is that I can drag-drop GUI elements. No 3 pages of code
to create a button.
Ah, that. Yes, I started with that too. But when I discovered Dialogs and
how I could add a button (or any other control) with just a single line in a
resource file I dropped the whole CreateWindowEx and all of that approach,
and used DialogBoxParam instead.
Post by Newyana2
I can see the appeal of building a ship in a bottle. I'm just too
practical to do all that work only to have an object to sit on a
bookshelf.
:-) My interrest is mosty towards figuring out how to get stuff working.
As a result I have a lot of "how does this work" test programs, which I
often abandon when I have a clear view of the harbour.

Regards,
Rudy Wieser

MummyChunk
2024-10-01 22:22:34 UTC
Permalink
Post by R.Wieser
Hello all
Using XPsp3
I was playing with the idea to dynamically alter the contents of a
ImageList, and found the
https://learn.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-imagelist_getimageinf
Post by R.Wieser
function, which says
"The information in this structure can be used to *directly
manipulate the
Post by R.Wieser
bitmaps for the image
(bolding mine)
I've been trying to think of how that is possible - the bitmap
cannot be
Post by R.Wieser
selected into a memoryDC - and to google information about how tha
would
Post by R.Wieser
work, but came up empty
Question
Does anyone know what "directly manipulate the bitmaps
method MS is
Post by R.Wieser
referring to in the above
Remark
I already thought of and written another way to do what I want, bu
would
Post by R.Wieser
like to know how the above works. Who knows, their (MS) metho
might be
Post by R.Wieser
simpler. :-
Regards
Rudy Wiese
The phrase “directly manipulate the bitmaps” i
the context of the ImageList_GetImageInfo function refers to accessin
and modifying the bitmap data directly through the IMAGEINF
structure. This structure provides you with handles to the bitmaps
which you can then manipulate using GDI functions

Here’s how you might approach this

Retrieve the IMAGEINFO structure: Use ImageList_GetImageInfo to ge
the IMAGEINFO for the image you want to manipulate

Access the bitmaps: The IMAGEINFO structure contains handles to th
image and mask bitmaps
Manipulate the bitmaps: You can use GDI functions like GetObject
SelectObject, and BitBlt to manipulate the bitmap data
While you can’t select the bitmaps directly into a memory DC, you ca
create a compatible DC, select the bitmap into it, and then perfor
your manipulation


This is a response to the post seen at
http://www.jlaforums.com/viewtopic.php?p=675002552#67500255
Loading...