Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Drawing 16x16 Icon

123 views
Skip to first unread message

Daniel

unread,
Dec 22, 1999, 3:00:00 AM12/22/99
to
Hello,

I want to do a very "simpel" thing. Draw an small Icon in 16x16. Now this
seems as an fairly easy task. Ive tried using TImage Assigning Icon.Handle,
even with the Stretch On it wont resize it to 16x16. Ive tryied to use
DrawIcon(), it also resizes the Icon to 32x32. DrawIconEx() SHOULD do the
work as you can enter the Width,Height. But Im getting a "invalid variant
type conversion"-exeption. the ErrorLine is:
DrawIconEx(pbCmd.Canvas.Handle,0,0,MainView.Icon,16,16,NULL,0,DI_NORMAL);

The HICON is Loaded from various ways as ExtractIcon & SHGetFileInfo.

Daniel

Maynard Philbrook

unread,
Dec 22, 1999, 3:00:00 AM12/22/99
to
it' seems that some where i help some one to do this..
you need to create a Tbitmap of the current size of the ICON. being a 32x32.
draw the ICON to that then use the Bitmap to as a source for the CopyRect to
the destination.
the destination rectangle will be 16x16 in size but the source will be what
ever the icon was originally.
P.s.
Set the StretchBltmode for the destination canvas to STRETCH_HALFTONE prior
to copying.

DC Lawrence

unread,
Dec 22, 1999, 3:00:00 AM12/22/99
to
Windows can't stretch draw icons. You need a 16x16 image handle.

Check out LoadImage and CopyImage in the Win32 API online help. I think
these can scale icons, but I'm not sure.

Another thing you could do is create a bitmap and draw the icon to that, and
then stretch the bitmap, but then you have to deal with masking.

If all else fails, there's always ImageEdit.

Davie Reed

unread,
Dec 22, 1999, 3:00:00 AM12/22/99
to
I usually stretchdraw it right onto a BitMap.
Davie
P.S. Are these 16 color Icons or 256 color or True color Icons?

Daniel

unread,
Dec 22, 1999, 3:00:00 AM12/22/99
to
16 colors...


Davie Reed <da...@smatters.com> wrote in message
news:386133B6...@smatters.com...

Davie Reed

unread,
Dec 22, 1999, 3:00:00 AM12/22/99
to
ok, well then just stretchdraw it onto a Bitmap.
Davie

Daniel

unread,
Dec 23, 1999, 3:00:00 AM12/23/99
to
Could you write s small oneline example?

Daniel


Davie Reed <da...@smatters.com> wrote in message

news:386147AA...@smatters.com...

Peter Below (TeamB)

unread,
Dec 23, 1999, 3:00:00 AM12/23/99
to
> I want to do a very "simpel" thing. Draw an small Icon in 16x16. Now this
> seems as an fairly easy task. Ive tried using TImage Assigning Icon.Handle,
> even with the Stretch On it wont resize it to 16x16. Ive tryied to use
> DrawIcon(), it also resizes the Icon to 32x32. DrawIconEx() SHOULD do the
> work as you can enter the Width,Height. But Im getting a "invalid variant
> type conversion"-exeption. the ErrorLine is:
> DrawIconEx(pbCmd.Canvas.Handle,0,0,MainView.Icon,16,16,NULL,0,DI_NORMAL);

You get the error because you use NULL. Delphi is not C, NULL is a predefined
Variant constant in Delphi, not a placeholder for 0 or Nil like in C.


Peter Below (TeamB) 10011...@compuserve.com)
No replies in private e-mail, please, unless explicitly requested!


0 new messages