This sample uses 4 techniques, and creates 4 versions of icons from the same image file.
Before the conversion, it resizes the source image to the size of 16x16. That means that with this sample you can convert any image to ico file.
Important Requires VFP9 and GdiPlusX to run.
https://github.com/VFPX/GDIPlusX
do locfile("system.app") with _screen.system.drawing as xfcdrawing * convert the original bitmap to ensure better quality and compatibility loresized = .bitmap.new(.bitmap.fromfile(getpict()), 16,16) * create icon object local loicon as xfcicon loicon = .icon.fromhandle(loresized.gethicon()) *** low quality icons * save sending filename loicon.save("c:\icon_save_filename_lowqual.ico") * save using stream local lostream as xfcmemorystream lostream = _screen.system.io.memorystream.new() loicon.save(lostream) strtofile(lostream.getbuffer(), "c:\icon_save_stream_lowqual.ico") *** high quality icons *** setting the tlquality flag to .t. * save sending filename loicon.save("c:\icon_save_filename_highqual.ico", .t.) * save using stream local lostream2 as xfcmemorystream lostream2 = _screen.system.io.memorystream.new() loicon.save(lostream2, .t.) strtofile(lostream2.getbuffer(), "c:\icon_save_stream_highqual.ico") endwith
Excellent work, Cesar.
ReplyDeleteAs always with your coded examples, its very easy to implement.
I'm looking forward to the .ico files.
Will they have both 16x16 and 32x32?
Keep up the good work! I'd like you to know your GDIplusx image handling developments are very much appreciated.
Este articulo se encuentra traducido al español en www.PortalFox.com
ReplyDelete-- Convertir BMP a ICONO - Parte 3 --
http://www.portalfox.com/article.php?sid=2542