55import android .os .Bundle ;
66import android .os .Environment ;
77import android .util .Log ;
8+ import android .view .View ;
89import android .widget .ImageView ;
910
1011import androidx .appcompat .app .AppCompatActivity ;
1112
1213import java .io .File ;
1314import java .io .FileNotFoundException ;
1415import java .io .FileOutputStream ;
16+ import java .sql .Time ;
1517import java .util .ArrayList ;
1618import java .util .List ;
1719
20+ import static com .adrino .renderscript .MainActivity .SCALE_THRUSHOLD ;
1821import static com .adrino .renderscript .MainActivity .SOURCE1 ;
1922import static com .adrino .renderscript .MainActivity .SOURCE2 ;
2023import static com .adrino .renderscript .MainActivity .SOURCE3 ;
@@ -24,6 +27,7 @@ public class Collapse extends AppCompatActivity {
2427 List <Bitmap > bmpImages ;
2528 private static final String TAG = "Collapse" ;
2629 private List <Bitmap > hdrOutput ;
30+ private boolean set = false ;
2731
2832 @ Override
2933 protected void onCreate (final Bundle savedInstanceState ) {
@@ -46,26 +50,58 @@ public void run() {
4650 }
4751 });
4852
53+ long start = System .currentTimeMillis ();
4954 hdrOutput = exposureFusion .perform (bmpImages , ExposureFusion .Actions .COLLAPSE );
55+ long end = System .currentTimeMillis ();
56+
57+ Log .e (TAG , "run: Total time : " +(float )(end - start )/1000 +" s" );
5058 runOnUiThread (new Runnable () {
5159 @ Override
5260 public void run () {
53- ((ImageView )findViewById (R .id .original )).setImageBitmap (bmpImages .get (0 ));
61+ ((ImageView )findViewById (R .id .original )).setImageBitmap (bmpImages .get (2 ));
5462 ((ImageView ) findViewById (R .id .hdr )).setImageBitmap (hdrOutput .get (0 ));
5563 }
5664 });
5765 }
5866 }).start ();
67+
68+ (findViewById (R .id .hdr )).setOnLongClickListener (new View .OnLongClickListener () {
69+ @ Override
70+ public boolean onLongClick (View v ) {
71+
72+ ImageView imgView = findViewById (R .id .expanded_image );
73+ if (!set ){
74+ if (hdrOutput !=null ) {
75+ imgView .setVisibility (View .VISIBLE );
76+ imgView .setImageBitmap (hdrOutput .get (0 ));
77+ set = true ;
78+ }
79+ }
80+ else {
81+ imgView .setVisibility (View .INVISIBLE );
82+ set = false ;
83+ }
84+
85+ return true ;
86+ }
87+ });
5988 }
6089
6190 List <Bitmap > generateResultant () {
6291 if (bmpImages == null ) {
6392 bmpImages = new ArrayList <>();
64- BitmapFactory .Options imgLoadOption = new BitmapFactory .Options ();
65- imgLoadOption .inSampleSize = ExposureFusion .SAMPLE_SIZE ;
66- bmpImages .add (BitmapFactory .decodeResource (getResources (), SOURCE1 , imgLoadOption ));
67- bmpImages .add (BitmapFactory .decodeResource (getResources (), SOURCE2 , imgLoadOption ));
68- bmpImages .add (BitmapFactory .decodeResource (getResources (), SOURCE3 , imgLoadOption ));
93+
94+ bmpImages .add (BitmapFactory .decodeResource (getResources (), SOURCE1 ));
95+ bmpImages .add (BitmapFactory .decodeResource (getResources (), SOURCE2 ));
96+ bmpImages .add (BitmapFactory .decodeResource (getResources (), SOURCE3 ));
97+
98+ int imgWidth = bmpImages .get (0 ).getWidth ();
99+ int imgHeight = bmpImages .get (0 ).getHeight ();
100+ int scaledWidth = imgHeight > imgWidth ? (imgWidth * SCALE_THRUSHOLD ) / imgHeight : SCALE_THRUSHOLD ;
101+ int scaledHeight = imgHeight > imgWidth ? SCALE_THRUSHOLD : (imgHeight * SCALE_THRUSHOLD ) / imgWidth ;
102+ for (int i = 0 ; i < bmpImages .size (); i ++) {
103+ bmpImages .set (i , Bitmap .createScaledBitmap (bmpImages .get (i ), scaledWidth , scaledHeight , false ));
104+ }
69105 return exposureFusion .perform (bmpImages , ExposureFusion .Actions .RESULTANT );
70106 }
71107 return null ;
0 commit comments