Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Search instead for 
Did you mean: 
kidasov
Level 7

Convert bitmap to png or jpg

I tried to use GetToFile method from here https://sdkdocs.roku.com/display/sdkdoc/ifUrlTransfer#ifUrlTransfer-GetToFile(filenameasString)asInt...
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?
0 Kudos
2 Replies
Roku Employee
Roku Employee

Re: Convert bitmap to png or jpg

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)
0 Kudos
kidasov
Level 7

Re: Convert bitmap to png or jpg

Yes. It was my bad. I missed it Smiley Happy And thank you!
0 Kudos