Forum Discussion

kidasov's avatar
kidasov
Channel Surfer
8 years ago

Convert bitmap to png or jpg

I tried to use GetToFile method from here https://sdkdocs.roku.com/display/sdkdoc/ifUrlTransfer#ifUrlTransfer-GetToFile(filenameasString)asInteger
It saves raw bitmap to file. Then I am trying to convert bitmap to png like this and remove file with bitmap.
urlTransfer.getToFile(fileName)           
            
bitmapImage = CreateObject("roBitmap", fileName)'            
bitmapImage = bitmapImage.GetPng(0, 0, 426, 249)
bitmapImage.WriteFile("tmp:/test.png")
            
DeleteFile(fileName)

But the size of file (426x249) is huge according to r2d2_bitmaps. 
0x27bfdf46   426    249   4   458752 /tmp/plugin/GEAAAAEweoqr/tmp:/test.png
Available memory 50984704 used 9015296 max 60000000

What I am doing wrong?
  • 458752 is not the size of the png file, it is the size of it loaded in memory/as a texture (roughly Width * Height * bpp)
  • kidasov's avatar
    kidasov
    Channel Surfer
    Yes. It was my bad. I missed it 🙂 And thank you!