WPF Icon
import clr clr.AddReference("PresentationFramework") clr.AddReference("PresentationCore"); clr.AddReference("System.Drawing") clr.AddReference('WindowsBase') import System import System.IO from System import * from System.Drawing import * from System.Windows.Media import * from System.Windows.Media.Imaging import * def FileToBase64(filename): with open(filename,"rb") as f: data = bytes(f.read()).ToByteArray() return Convert.ToBase64String(data) def Base64ToFile(filename,data): with open(filename,"wb") as f: byteArray = Convert.FromBase64String(data); f.write(bytes(byteArray)) def GetImageFile(filename): return BitmapImage(System.Uri(filename,System.UriKind.Relative)) def GetBitmapFrameFromFile(filename): return BitmapFrame.Create( System.Uri(filename, System.UriKind.RelativeOrAbsolute)) def GetMemImageStream(str): byteArray = Convert.FromBase64String(str) return System.IO.MemoryStream(byteArray) def GetBitmapFrame(image): return BitmapFrame.Create( GetMemImageStream(image), BitmapCreateOptions.None, BitmapCacheOption.OnLoad) # API exit_png = "iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAGT0lEQVR42qWXe0xTVxzHv7dAsVRBQZ5T8IHCggZ06NSF6DKNOqPLotuMMdmWGcXNqSM6jYuZcTPO7Z9lS/aIzPkYOECdwSHNVJI5iA9QDA8ZAwQs0EKBQhFKub337Jx7b28LLObWHSjn9qT8vp/f9/zO795y0DA6sl8iWj7nz4jbVsaxmdPyYfOPy0jx3XafFaLtXznlo8oQgydD5+qT1rdnt2oHaP5+Kfmjoh07fnrsV5YR8UmYm7ERyRmbYIybj4d1Lnxj3ICy+03YccoPgMZvXyTXKy3IPPV0gNDoeMxatAapq99FZOIi6AURIYIAMiyixeLG1QoXTOmbcauqkcXSDlD39WLyZ5V1HIAxPAbxacuRtnY7ImJnIjR8GqZARAAvQnCLcAtQXgQ9AwQXy4ZxJe1NVNQ2I/NnPxyo/uoFUlprw87TMsDLmV8iacl6TI1JRDgnwiCKEAWvoCAS8Gxm7+m12w0MjRDk3RzGpXmbUPl3C94/7YcD948vJLfqu/GBArDhAo9XJ/IIABOgLzehorI4TwUFmrG8DmVdB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u8CxIlSajp3ebLoHBNp0AM+DoGS7dyMloK2P0jAlmuBooUV7J/xwgZFMfi4Un/3uBRgotwJBRiosSuKOQfpQ4rORkjjHZIkk4kF5q2E+ImN1LJb2e0HmPAOZmhCGz4usKkD1VTOGxUl44hSpkCcM8clZFvb5I/3dWJeCmGmBOFbkB8B7yXoSMyscx656AW7ktoDTh0mVPVqH84p77VBr4bWqFEyfEURj+QHwdmIQiZsTgePFXoDrOS20EYVCTd5z0IFxhecLte7B80iYpWextANsnRlApidF4rhpNADHAMZE4RQYDqNPNqe4sPpeMmYnTqCx/HBg83QdSUiJwgkfgGvMAX2o1N9ZZE79GsSp597zBYrzsAiDWHM/FbOTjPjC5IcDYwcFIDfye+njBRfmyVSqeKJUO0dU0+lNqJ9eltAr2uthGsiLGvXl4pkBrlMAehmmJuq7DQSlNDK9u+HaYH506dNi/W8AJchjCmGis4nuSIkzP7pfa6xnAmDD8EZnDp3u0leRsyC68Vnj/As+l/pOB/618gAAAABJRU5ErkJggg==" def GetExitBitmapImage(): return GetBitmapFrame(exit_png) def GetExitImage(): return System.Drawing.Image.FromStream(GetMemImageStream(exit_png)) if __name__ == "__main__": data = FileToBase64("D:/exit.png") print(data) Base64ToFile("D:/a.png",data)
댓글 없음:
댓글 쓰기