Results 1 to 5 of 5

Thread: VB6 Icon Maker

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Dec 2012
    Posts
    1,470

    VB6 Icon Maker

    I was having difficulty finding appropriate Icons that could be added to VB6 programs, and using online Icon tools was a real pain. So I found an older Bmp2Icon program code, but it was overly complex, difficult to use, and contained a lot of unused code (4 forms, 4 modules, 2 Classes, and 2 User Controls). Attached is my attempt at a much simplified version.

    The sample shown below used 3DLRSIGN.WMF from the VB6 graphics collection, changed the aspect ratio to make it square, changed the background from white to red, shrunk it to the size of a 32 x 32 icon, and saved it in Icon format. It was then used as the Icon for the program.

    I have very little graphic experience, and I expect that the code could be simplified further. Even though I changed the background to red, the Icon showed up with a translucent background, and when I viewed the Icon with Paint, it showed up as a red dollar sign with a white background (?????).

    J.A. Coutts
    Attached Images Attached Images   
    Attached Files Attached Files

  2. #2
    Hyperactive Member
    Join Date
    Sep 2014
    Posts
    373

    Re: VB6 Icon Maker

    I happen to pass by, so I have a run of your project. The source image GIF and the resulting ICO are enlosed in the appended ZIP, and below is my testing report:

    (1) The source is GIF, hence it is expected that the ICO should be 8-BPP (color count not exceeding 256), not 24-BPP. Since it is done on 24-BPP basis, this point is noted for your future improvement only, not considered as an error at your this stage.

    (2) The source GIF has a designated transparent color (which is grayish), you should display all original colors including the designated transparent color, because the designated transparent color is a unique color in the entire image. If you let user have a chance to select this color, then it is guaranteed that the same color would not appear in the painted area. If you display it with a default white background (the color seen through the transparent color area), then there is no guarantee that there won't the same white color in the painted area. Again this point is noted for your reference only, not considered as an error at your this stage.

    (3) The entry in .dwBytesInRes field of IDE is incorrect. It should be 3240, not 3244.

    (4) The entry in .biSizeImage field of BIH is incorrect. It could be left as 0, because bytes are uncompressed. Since you enter a figure, then the correct figure should be 3270, not 1153.

    A good attempt on your part. The report is nothing but for your future improvement only.
    Attached Files Attached Files
    Last edited by Brenker; Feb 21st, 2018 at 01:02 PM.

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Dec 2012
    Posts
    1,470

    Re: VB6 Icon Maker

    Thank you for the feedback. You obviously have more experience at this than I do. I do not even know what ".dwBytesInRes" & ".biSizeImage" actually do, as that was borrowed code from a program that was very old and did not work very well. Do they have anything to do with the strange color variations that I experienced?

    J.A. Coutts

  4. #4
    Hyperactive Member
    Join Date
    Sep 2014
    Posts
    373

    Re: VB6 Icon Maker

    couttsj,

    Do they have anything to do with the strange color variations that I experienced?
    I've looked at your code for the first time this morning and my answer to your above question is "No". It is very likely that the strange color variation is caused by the code line:

    Put #1, , " "

    in SaveIcon24Bits()

    Please do the following in SaveIcon24Bits()

    (1) Delete the line I mentioned above.
    (2) Replace the figure "3244" with "3240" (for good order sake you still have to do this, after deleting the line in "1")
    (3) Replace the figure "1153" with "3270" (or just "0", see my earlier posting)

    While we are here, I would suggest you to provide a chance for user to click on the PictureBox containing the source image to select the transparent color, instead of using a color dialong. Think of this, if the color user wants to select is RGB(123, 146, 169), how would he/she be able to select such a color from your color dialog? You have to ensure that to be effective, the designated transparent color is in existence in the image.

    Edited:
    -- The attached image shows the difference between the "old" and "new" icons.

    -- Another critical point I want to raise (it escaped my sight before): Your file dialog allows ICO to come in; you shouldn't, because your existing project doesn't cover 32-BPP files (yet). If a user loads a 32-BPP ICO file, your current project would show the image per its raw bytes only, without a so-call "premultiplied" to show the alpha effects. In future when your project can deal with 32-BPP images: (A) If still save to ICO on 24-BPP basis, then you would show the image with alpha effects (different to the case of GIF when you should show all original colors), disable "Background" button after loading a 32-BPP file and automtically honour a designated transparent color (with reference to alpha value 0), and ideally, allow user to select an "alpha cutoff" point say from 0 to 128 (in order to elimiminate fringe effects brought about by smaller alpha values). (B) If save to ICO on 32-BPP basis, then just show icon image on 32-BPP basis and disable "Background" button.

    -- This is just hairs splitting, when the source is already 32x32, dim the "Resize" button

    -- Finally, just to clear away a possible puzzle you might have in mind: I said that I read your code for the first time this morning, how would I know the figure "3244" last time? My own program checks certain discrepancies in the files on their loading, and flags a message to remind the user of a discrepancy found (so that he/she can resave the file using my own program), examples are the resultant ICO of your this project, CRC error in a PNG file, a TIFF with JEPG compression being loaded on systems before Win 7, etc. That is why I knew the figure "3244" before I read your code.

    I've done my part, it is your turn now. Wish you good luck.

    Brenker



    Edited2:
    ZIP containing 32-BPP ICO file for test attached
    Attached Images Attached Images   
    Attached Files Attached Files
    Last edited by Brenker; Feb 22nd, 2018 at 10:22 AM.

  5. #5
    Hyperactive Member
    Join Date
    Sep 2014
    Posts
    373

    Re: VB6 Icon Maker

    couttsj,

    I've taken a 2nd look of your code today and appended a few more points under "Edited:" (in order to put pieces in one place).

    Brenker

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width