Search code examples
androidbitmapandroid-ndkbitmapfactory

how to save "bmp" as bmp file in sd card?


Now I'm trying to get a frame picture from video file and I know how to do it(with ffmpeg or getFrameAtTime function)

so I can get a frame as bmp structure in my program but when I save this as png or jpeg,

these quality are not good although video's quality is fine

so I wanna save this bmp without any compress

from what I hear copyPixelsToBuffer function works for this but I couldn't do it... T_T...

please anyone can explain to me how to use this?? //my recording size is (1280, 720)

should I record a video in more bigger size? or should I save frame as bitmap in sd card???

without compress???

//my guess is it's for compression. compress is a kind of trade off with quality

now I used this function to make a png or jpeg Bitmap.compress(CompressFormat.PNG, 100, fos)


Solution

  • From Wikipedia: http://en.wikipedia.org/wiki/Portable_Network_Graphics

    Portable Network Graphics (PNG /ˈpɪŋ/[2] ping) is a bitmapped image format that employs lossless data compression.

    The PNG compression you're doing with the code you show is not losing any quality. PNGs are lossless.

    What is most likely happening is that the implementation to get the bitmap object into your memory is losing some pixels somewhere.

    I suggest you (for comparison and testing purposes) to show the bitmap object in an ImageView full screen on your application and compare it with the saved PNG. Just to check which conversion is really losing quality.