Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
kidasov
Channel Surfer

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 2
RokuNB
Roku Guru

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
Channel Surfer

Re: Convert bitmap to png or jpg

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