The MASM Forum

General => The Campus => Topic started by: daydreamer on August 24, 2020, 09:46:13 PM

Title: what makes and breaks Icons?sizecontrol?
Post by: daydreamer on August 24, 2020, 09:46:13 PM
I am trying different sizes of icons and trying to use them on buttons and draw them with icondraw and icondrawex
100,100 buttons use centered small icon sizes around 40x40 (checking screenshot)
icondrawex only makes use of smaller size of icon,so bigger sizes in icondrawex size only draws smaller lowres icon upsized which looks terrible
any way to control Loadicon a resource or something else to control buttons and icondrawex to use the biggest 256x256 icon,or 128x128?
Title: Re: what makes and breaks Icons?sizecontrol?
Post by: fearless on August 24, 2020, 10:03:25 PM
Can look at LoadImage and using IMAGE_ICON and specifying size, or try LoadIconWithScaleDown or LoadIconMetric functions
Title: Re: what makes and breaks Icons?sizecontrol?
Post by: TouEnMasm on August 24, 2020, 10:48:27 PM
When you have really specific needs with buttons ,an owner drawn button can be a soluce.
you can search here: http://www.massmind.org/images/www/asmedit/AsmMain.html (http://www.massmind.org/images/www/asmedit/AsmMain.html) with no update,"Helas".
or you can test one of it's creation in the zip.
Title: Re: what makes and breaks Icons?sizecontrol?
Post by: daydreamer on August 26, 2020, 01:34:17 AM
thanks Yves for the tool :thumbsup:
Quote from: fearless on August 24, 2020, 10:03:25 PM
Can look at LoadImage and using IMAGE_ICON and specifying size, or try LoadIconWithScaleDown or LoadIconMetric functions
thanks that works to get big icons and suddenly 2 of my test drawiconex works
one with 256,256 size and one that has 0,0 size and DEFAULTSIZE as flag :thumbsup:
one looks little darker,used DEFAULTCOLOR flag have something todo with it?
but stretchblt or GDI+ might draw resized Icons with antialias?

so many HANDLES/HICON after each other,I can treat it as animation frames
many image buttons in a row can be for different spells
Title: Re: what makes and breaks Icons?sizecontrol?
Post by: daydreamer on August 28, 2020, 04:20:30 AM
I think array of Icons and array cursors would be better way to organize them ,just tiny LUT to control animation
hIcons[0] = LoadIcon(hInst, IDI_APPLICATION);
hIcons[1] = LoadIcon(NULL, IDI_ASTERISK);
hIcons[2] = LoadIcon(NULL, IDI_EXCLAMATION);
hIcons[3] = LoadIcon(NULL, IDI_QUESTION);
hIcons[4] = LoadIcon(NULL, IDI_HAND);
hIcons[5] = LoadIcon(hInst,MAKEINTRESOURCE(IDI_SMALL));
hIcon1 = LoadIcon(NULL, IDI_QUESTION);
hIcon2 = LoadIcon(hInst, MAKEINTRESOURCE(201));
//hIcon3 = LoadIcon(hInst,MAKEINTRESOURCE( IDI_WTEST));
hIcon3 =(HICON) LoadImage(hInst, MAKEINTRESOURCE(IDI_WTEST), IMAGE_ICON, 256, 256, LR_DEFAULTCOLOR);


in paint alternative drawex with DI_DEFAULTSIZE uses 256x256 or whatever size icon is,just use 0,0
DrawIcon(hdc, 600, 400, hIcon2);
DrawIconEx(hdc, 800, 0, hIcon2, 256, 256,0, NULL, DI_NORMAL);
DrawIconEx(hdc, 800, 300, hIcon1, 256, 256, 0, NULL, DI_NORMAL);
DrawIconEx(hdc, 1000, 0, hIcon3, 0, 0, 0, NULL, DI_NORMAL);
DrawIconEx(hdc, 1000, 300, hIcon3, 0, 0, 0, NULL, DI_NORMAL | DI_DEFAULTSIZE);
DrawIconEx(hdc, 1000, 500, hIcon3, 256, 256,0, NULL, DI_NORMAL);

DrawIcon(hdc, i*20, j*20, hIcon2);//Rectangle(hdc, i * 20, j * 20, i * 20 + 19, j * 20 + 19);
Title: Re: what makes and breaks Icons?sizecontrol?
Post by: daydreamer on September 05, 2020, 08:49:55 PM
Quote from: fearless on August 24, 2020, 10:03:25 PM
Can look at LoadImage and using IMAGE_ICON and specifying size, or try LoadIconWithScaleDown or LoadIconMetric functions
I make macro that creates button ,percentages of screensizes,also percentage of screenheight/screenwidht controls position so it works in any resolution ,just above 768 to above hires 1080 and LoadImages matching buttonsizes
Title: Re: what makes and breaks Icons?sizecontrol?
Post by: hutch-- on September 06, 2020, 12:14:09 AM
Magnus,

If you can make sense of what you are after, icons come in fixed sizes and when multiple sizes are required, they are written into the same icon file which makes them bigger. One trick is to make an icon the biggest size you need but only have one image in the icon file as the OS resizes icons to fit like in the top left of the window and some about boxes.

Multi-resolution icons look the best but single sized icons are usually smaller.

Get yourself a decent icon editor, the Axialis Icon Workshop is a very good tool.
Title: Re: what makes and breaks Icons?sizecontrol?
Post by: daydreamer on September 07, 2020, 06:39:56 AM
Quote from: hutch-- on September 06, 2020, 12:14:09 AM
If you can make sense of what you are after, icons come in fixed sizes and when multiple sizes are required, they are written into the same icon file which makes them bigger. One trick is to make an icon the biggest size you need but only have one image in the icon file as the OS resizes icons to fit like in the top left of the window and some about boxes.

Multi-resolution icons look the best but single sized icons are usually smaller.

Get yourself a decent icon editor, the Axialis Icon Workshop is a very good tool.
thanks Hutch :thumbsup:
Title: Re: what makes and breaks Icons?sizecontrol?
Post by: hutch-- on September 07, 2020, 12:05:37 PM
Magnus,

Icons are usually used in standard sizes and while you can build non standard sized icons, they are normally in pixel square sizes, 16, 32, 48, 64, 96, 128, 256, and even 512 on late OS versions.

You load them with LoadImage() and in normal contexts like in the client area, you use DrawIconEx() called from a WM_PAINT to display an icon at whatever location you want.
Title: Re: what makes and breaks Icons?sizecontrol?
Post by: Vortex on September 08, 2020, 05:08:40 AM
Hi daydreamer,

Here is an example for you. It displays an icon in the client area of a window.
Title: Re: what makes and breaks Icons?sizecontrol?
Post by: daydreamer on September 08, 2020, 08:31:10 AM
I need to find later version of resource compiler,this one gives error message when. Ico files are compressed, now when I tried different compressor alternatives, 8bit and 32bit compressed
File sizes goes down to ca 60kb when its very detailed artwork, to b/w simple goes down to only 4.05 kb
Thanks Erol

Title: Re: what makes and breaks Icons?sizecontrol?
Post by: Vortex on September 08, 2020, 04:27:37 PM
Hi daydreamer,

As we know, the latest versions of Visual Studio are providing rc.exe , the MS resource compiler. Some alternatives are Pelle's resource compiler, Jeremy Gordon's GoRc and windres the GNU resouce compiler.
Title: Re: what makes and breaks Icons?sizecontrol?
Post by: daydreamer on September 09, 2020, 06:02:02 AM
Quote from: Vortex on September 08, 2020, 04:27:37 PM
As we know, the latest versions of Visual Studio are providing rc.exe , the MS resource compiler. Some alternatives are Pelle's resource compiler, Jeremy Gordon's GoRc and windres the GNU resouce compiler.
rc.exe combined with cvtres.exe was used previously,was only able to find cvtres.exe,seem rc.exe is integrated in VS,maybe inside on of these .dll file
so I found GoRC ,which is capable of RC files->.obj files directly,works great,also with compressed .ico files :thumbsup:
10 big Icons +350kb on .exe

Hutch ,is LoadImage from file going to be same limits as the OS it is run on:pre-vista OS incapable of compressed 256x256.ico files?,512x512 .ico only on win10 ?
Title: Re: what makes and breaks Icons?sizecontrol?
Post by: hutch-- on September 09, 2020, 10:36:31 AM
Magnus,

RC.EXE from 10 years ago will do the job correctly when it comes to resources. The same with cvtres.exe. An icon is a specific file format and you must make them correctly for them to work.

LoadImage has been around since Win NT 4 and its nothing new, what changes is the OS and with the current Windows version, you can use icons up to 512 x 512 pixel but they end up really large file sizes. Your real use of icons apart from a desktop icon is being able to use DrawIconEx() from a WM_PAINT message where you need the transparency when drawn over different backgrounds.

If you just need to display an image, use a BMP or a JPG if you know how to load them. Pelle's resource compiler works fine but I have never used Jeremy's version so you will have to test that yourself.
Title: Re: what makes and breaks Icons?sizecontrol?
Post by: daydreamer on September 13, 2020, 01:27:05 AM
I think I need a secondary system drawing only moving Icons and only the underlying "tile" to reduce flicker from WM_TIMER
+ and - moves up and down level

mouse button = move player here
just testing
Title: Re: what makes and breaks Icons?sizecontrol?
Post by: daydreamer on November 17, 2020, 09:53:07 AM
I am using about 50 Icons loaded from file and windows program get a delay before it pops up and I tested VS memorytool and it got a memory usage 9mb peak right after start,before it goes down and stabilize above 2mb,some unpackaging .ico files maybe followed by some internal compression format?
no problem just wanted to share info
only problem is to fit project somewhere else
Title: Re: what makes and breaks Icons?sizecontrol?
Post by: hutch-- on November 17, 2020, 04:39:05 PM
Magnus, 50 icons are a lot of icons, are you looking for magic ?
Title: Re: what makes and breaks Icons?sizecontrol?
Post by: daydreamer on November 19, 2020, 06:39:30 PM
Quote from: hutch-- on November 17, 2020, 04:39:05 PM
Magnus, 50 icons are a lot of icons, are you looking for magic ?
http://masm32.com/board/index.php?topic=8419.0 (http://masm32.com/board/index.php?topic=8419.0)
50 flower images in newest version of this makes it easier recognize picture of flower than only name and looks better
JJ showed earlier some code that retrieved data from internet,possible to Load images and icons from internet ,where I have my flower pics stored?
Title: Re: what makes and breaks Icons?sizecontrol?
Post by: jj2007 on November 19, 2020, 08:02:37 PM
Quote from: daydreamer on November 19, 2020, 06:39:30 PMJJ showed earlier some code that retrieved data from internet,possible to Load images and icons from internet ,where I have my flower pics stored?

URLs?