package com.ar.imagetracear.utils;

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 ImageLoader {

    public static Bitmap loadBitmapFromFile(String filePath) {
        return BitmapFactory.decodeFile(filePath);
    }

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

    public static void displayBitmapInView(ImageView targetImageView, Bitmap imageBitmap) {
        if (imageBitmap != null) {
            targetImageView.setImageBitmap(imageBitmap);
        }
    }
}
