Converting a picture to an Icon

Converting a picture to an Icon

Post by er12 » Wed, 14 May 2003 20:28:01



Mike,

Thank you for taking the time to offer me some suggestions about converting
a picture to an icon.

The first suggestion was too simple to work.

I had for a while thought about creating the icon completely in memory and
then allocating it. that seemed rather daunting, so thank you for showing me
an example of how to do it.

Unfortunately - the code creates an icon, and saves it to fil OK BUT

- I cannot use the resultant icon
- the part in the code which  draws the icon
(        Call DrawIconEx(Picture2.hDC(), 10       , 10  , hIcon, 0, 0, 0, 0,
DI_NORMAL)
        Call DrawIconEx(Picture2.hDC(), 10       , IconHeight + 20 , hIcon,
0, 0, 0, 0, DI_IMAGE)
        Call DrawIconEx(Picture2.hDC(), IconWidth + 20, IconHeight + 20 ,
hIcon, 0, 0, 0, 0, DI_MASK)
)

doesn't draw anything.
- the icon fili is recognised as an icon - in that I can allocate it to
something on my desk top, but VB will not load it - "invalid format"
also I can't open it say in Corel - "Invalid header".

What is happening - can there be a reason that VB doesn't recognise the
structure of the icon file? I tried a couple of different screen settings to
see if that helped - but it didn't.

If you can't help further, thank you for your rime anyway,

Eric Raymond

 
 
 

Converting a picture to an Icon

Post by Richard Maso » Thu, 15 May 2003 20:11:21


On Tue, 13 May 2003, er123 wrote in
<microsoft.public.vb.winapi.graphics>

Quote:>What is happening - can there be a reason that VB doesn't recognise the
>structure of the icon file? I tried a couple of different screen
>settings to see if that helped - but it didn't.

TrueColor on most displays actually displays images at 32 bit so when
you run the app with a TrueColor desktop you get a 32 bit icon - an XP
icon - and VB can't use XP icons.

--
Richard Mason

 
 
 

1. Converting a picture to an Icon

Repost as my last message didn't appear.

I am trying to convert a picture to an Icon - so that I can have a paste
function to change the application icon.

I originally wrote my program in VB3 and used the code below (Originally
fron the Icon Editor in VB3)
(The new picture is in the processbox and there is an existing icon in the
active control ( The getbitmapbits simply replaces the bitmap).

    lp = GlobalLock(Screen.ActiveForm.ActiveControl.Picture)
    re = GetBitmapBits(Screen.ActiveForm.processbox.Image, 512, lp + 12 +
128)
    res = GlobalUnlock(Screen.ActiveForm.ActiveControl.Picture)

the activecontrol and the processbox are both picturebox controls

Now in VB6 the value returned by the GlobalLock function is 0 - so the
codefor GetBitmapBits
fails

Does anyone know why? Or is there a better way to create the icon in the
picturebox?

Any help would be apreciated.

Eric Raymond

2. Problem with JPG

3. Converting a Picture to an Icon

4. Render Callbacks

5. convert icon to picture

6. Rotating about an axis(Performer or Vega)

7. Converting Large Icons to Small Icons

8. Screen Resolution

9. Problem converting Mac Icons to Windows Icon

10. Sub Color2Gray(Icon as Picture) as Picture ???

11. Convert Picture in Picture with numerated Points

12. Convert Handle of picture (hBmp) in Address of data of picture

13. ICONS - CREATING ICON.DLL or ICON.EXE FROM *.ICO