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