package com.ar.ardrawingboard.util;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.widget.ImageView;

import java.io.IOException;
import java.io.InputStream;

public class ImageUtils {

    public static Bitmap loadBitmapFromStorage(String path) {
        return BitmapFactory.decodeFile(path);
    }

    public static Bitmap loadBitmapFromAssets(Context context, String path) {
        try (InputStream inputStream = context.getAssets().open(path)) {
            return BitmapFactory.decodeStream(inputStream);
        } catch (IOException e) {
            e.printStackTrace();
            return null;
        }
    }

    public static void displayImageToImageView(ImageView imageView, Bitmap bitmap) {
        if (bitmap != null) {
            imageView.setImageBitmap(bitmap);
        }
    }
}