Take a 256x256 bitmap and just check alpha. Make sure bmp is 32 bit. Any part that has 0 for a pixel value (i.e. BGRA 0,0,0,0 uses TBitmap.Scanline for access) is transparent. You can find the smallest x and the smallest y coordinate, which has a nonzero value and the actual size of your icon. Now this number may be smaller than the size of the icon as it was designed. For example, a 16x16 icon might contain a 2x2 image, which would be a weird design.
But of course, the 8x16 icon is quite possible. Given that the images are always square, take max if the x and y coordinates found (c and the height of the actual image) and round it to the nearest of 16,24,32,48,64,128 or 256. You can be absolutely sure that you will have An icon centered in your bitmap if you crop this size as follows. Use Bmp.Width=sz; Bmp.Height=sz; . Then you can scale it or center it on a standard bitmap (56x56 Γ 256x256?).
So, even if the windows do not want to give you the correct information, you can bypass this information simply by learning about yourself. This may not be the βrightβ way to do this, but you will know that it will work when you finish, as opposed to viewing MSDN for 4 hours and never finding an answer.
source share