第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

Android Java中如何將位圖轉(zhuǎn)換為圖像

Android Java中如何將位圖轉(zhuǎn)換為圖像

ibeautiful 2023-10-13 10:26:51
我想將我的位圖轉(zhuǎn)換為圖像,而不是可繪制的圖像,我已經(jīng)看到了一些示例,他們正在將位圖轉(zhuǎn)換為可繪制的圖像,但我需要 media.image(image) ,然后我用進(jìn)一步的邏輯處理該圖像。幫我解決這個(gè)問題簡而言之,我需要將位圖轉(zhuǎn)換為圖像。 Bitmap original_with_water_mark= addWatermark(original_image_bitmap,water_mark_bitmap,300);我需要original_with_water_mark bitmap將其轉(zhuǎn)換為要存儲(chǔ)的圖像。但我不知道如何將該位圖轉(zhuǎn)換為圖像因?yàn)樵谶\(yùn)行函數(shù)中,在開始時(shí)看到我需要mImage哪個(gè)是我必須存儲(chǔ)的圖像 @Override        public void run() {            ByteBuffer buffer = mImage.getPlanes()[0].getBuffer();            byte[] bytes = new byte[buffer.remaining()];            buffer.get(bytes);            FileOutputStream output = null;            try {                output = new FileOutputStream(mFile);                output.write(bytes);            } catch (IOException e) {                e.printStackTrace();            } finally {                mImage.close();                if (null != output) {                    try {                        output.close();                    } catch (IOException e) {                        e.printStackTrace();                    }                }            }        }
查看完整描述

2 回答

?
慕姐4208626

TA貢獻(xiàn)1852條經(jīng)驗(yàn) 獲得超7個(gè)贊

yu can use:-


    private void save(){ 

    SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss", Locale.ENGLISH);

    filename = sdf.format(new Date());


    try {

        String path = getApplicationContext().getFilesDir().getPath();

        OutputStream fOut = null;

        File file = new File(path, "MYFile"//your file name);

        if (!file.exists()) {

            file.mkdirs();

        }


        File file2 = new File(file, filename + ".png");

        fOut = new FileOutputStream(file2);



        //your bitmap

        original_with_water_mark.compress(Bitmap.CompressFormat.PNG, 100, fOut);

        fOut.flush();

        fOut.close();

    }

}


查看完整回答
反對(duì) 回復(fù) 2023-10-13
?
慕娘9325324

TA貢獻(xiàn)1783條經(jīng)驗(yàn) 獲得超4個(gè)贊

您可以將其以任何圖像格式保存在本地存儲(chǔ)中。


private void storeImage(Bitmap image) {

File pictureFile = getOutputMediaFile();

if (pictureFile == null) {

    Log.d(TAG,

            "Error while creating media file, Please ask for storage permission");

    return;

try {

    FileOutputStream fos = new FileOutputStream(pictureFile);

    image.compress(Bitmap.CompressFormat.PNG, 90, fos);

    fos.close();

} catch (FileNotFoundException e) {

    Log.d(TAG, "File not found: " + e.getMessage());

} catch (IOException e) {

    Log.d(TAG, "Error accessing file: " + e.getMessage());

}  

}


private  File getOutputMediaFile(){


File mediaStorageDir = new File(Environment.getExternalStorageDirectory()

        + "/Android/data/"

        + getApplicationContext().getPackageName()

        + "/Files"); 



if (! mediaStorageDir.exists()){

    if (! mediaStorageDir.mkdirs()){

        return null;

    }

}  

String timeStamp = new SimpleDateFormat("ddMMyyyy_HHmm").format(new Date());

File mediaFile;

    String mImageName="MI_"+ timeStamp +".jpg";

    mediaFile = new File(mediaStorageDir.getPath() + File.separator + mImageName);  

return mediaFile;

}


查看完整回答
反對(duì) 回復(fù) 2023-10-13
  • 2 回答
  • 0 關(guān)注
  • 128 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)