java - From int[] to image png -


for project i'm working on hiding text in images using steganography. i've realized class in app ask me select image (.png) , modify least significant bit of every pixel. problem i've array of integer have create new image (.png) , save external memory. how can this? ps: cannot use bufferedimage!

this code until when least significant bits modified.

package com.dev.paolo.sicinf;  import android.content.cursorloader; import android.content.intent; import android.database.cursor; import android.graphics.bitmap; import android.graphics.bitmapfactory; import android.net.uri; import android.os.bundle; import android.provider.mediastore; import android.support.v7.app.actionbaractivity;  import java.io.file; import java.math.biginteger; import java.sql.sqlexception;  public class sendkey extends actionbaractivity{  private static final int file_select_code=0;  public void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     intent intent = new intent(intent.action_get_content);     intent.settype("file/");     startactivityforresult(intent.createchooser(intent, "select image"), file_select_code); }  @override protected void onactivityresult(int requestcode, int resultcode, intent data) {     super.onactivityresult(requestcode, resultcode, data);     switch (requestcode)     {         case file_select_code:             if(resultcode==result_ok)             {                 uri uri2 = data.getdata();                 string[] proj = {mediastore.images.media.data};                 cursorloader cursorloader = new cursorloader(this,uri2,proj,null,null,null);                 cursor cursor = cursorloader.loadinbackground();                 int column_index=cursor.getcolumnindexorthrow(mediastore.images.media.data);                 cursor.movetofirst();                 string uri = cursor.getstring(column_index);                 file file = new file(uri);                 bitmap img = bitmapfactory.decodefile(uri);                 int height = img.getheight();                 int width = img.getwidth();                 int[] pixel = new int[height * width];                 img.getpixels(pixel, 0, width, 1, 1, width-1, height-1);                 string key = "prova";                 byte[] b = key.getbytes();                 int count = 0;                 (byte current_byte : b) {                     (int j = 7; j >= 0; j--) {                         int lsb = (current_byte >> j) & 1;                         pixel[count] = (pixel[count] & 0xfffffffe) + lsb;                         count++;                     }                 }                 //from int[] create image , save external memory             }             break;     } } 

}

use bitmap.createbitmap(int[] colors, int offset, int stride, int width, int height, bitmap.config config) create bitmap object. use bitmap.compress() write file


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -