Skip to content

Instantly share code, notes, and snippets.

@Lwdthe1
Lwdthe1 / PhotoScalerAndSaver.java
Last active January 15, 2022 02:03
A demonstration of three Java functions for scaling a photo's bitmap and saving it to a file without contorting the photo's dimensions. This is in response to this stackoverflow question: http://stackoverflow.com/questions/16060143/android-take-photo-and-resize-it-before-saving-on-sd-card/36210688#36210688
public class PhotoScalerAndSaver {
public static main(String[] args) {
//TODO: create your photo here
//Convert your photo to a bitmap
Bitmap photoBm = (Bitmap) "your Bitmap image";
//scale and save the photo to a file on the directory
saveScaledPhotoToFile(Bitmap photoBm)