SOLVED: Problem converting Png file to Ico lazarus / 39-Graphics ---------------------------------------------------------------------- AsleyCruz · 2020-03-12 03:35 Hi team, I don't know to much about this but I am having problem with this code. I want to convert a PNG file to ico and save it to ico file. Please help me solve this. Many thanks team. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i var  vIcon: TIcon;  vPNG: TPortableNetworkGraphic;begin  vPNG := TPortableNetworkGraphic.Create;  vIcon := TIcon.Create;  try    vPNG.LoadFromFile('C:\Users\UserName\Desktop\information.png');    vIcon.Assign(vPNG);    vIcon.SaveToFile('C:\Users\UserName\Desktop\myIcon.ico');             finally    vPNG.Free;    vIcon.Free;  end;end; Error: Cannot assign a TPortableNetworkGraphic to a TIcon. ---------------------------------------------------------------------- avk · 2020-03-12 04:28 This works for me: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i ...begin  with TPicture.Create do    try      LoadFromFile('Png1.png');      Icon.SaveToFile('icon1.ico');    finally      Free;    end;  end; ---------------------------------------------------------------------- AsleyCruz · 2020-03-12 05:22 Quote from: avk on March 12, 2020, 05:28:56 amThis works for me: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i ...begin  with TPicture.Create do    try      LoadFromFile('Png1.png');      Icon.SaveToFile('icon1.ico');    finally      Free;    end;  end;  Thanks avk, it worked And if I wanted to save that png to stream (not a file) , what would be the change? ---------------------------------------------------------------------- GAN · 2020-03-12 05:28 https://lazarus-ccr.sourceforge.io/docs/lcl/graphics/tpicture.html SaveToStream does not work?