Skip to content

Commit 070ae0b

Browse files
Merge pull request #8 from AdarshRevankar/library-creation
HDR Library Created + Documentation
2 parents 6dc49f3 + 76aec11 commit 070ae0b

35 files changed

+910
-415
lines changed

.idea/inspectionProfiles/Project_Default.xml

Lines changed: 36 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,10 @@ dependencies {
3030
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
3131
implementation 'com.github.bumptech.glide:glide:3.7.0'
3232

33+
3334
testImplementation 'junit:junit:4.13'
3435

3536
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
3637
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
38+
implementation project(path: ':hdr')
3739
}

app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
android:roundIcon="@mipmap/ic_launcher_round"
1616
android:supportsRtl="true"
1717
android:theme="@style/AppTheme">
18+
<activity android:name=".hdr"></activity>
1819
<activity android:name=".Pyramids" />
1920
<activity android:name=".Collapse" />
2021
<activity android:name=".MainActivity">

app/src/main/java/com/adrino/renderscript/Collapse.java

Lines changed: 30 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.adrino.renderscript;
22

3+
import android.content.Context;
34
import android.graphics.Bitmap;
45
import android.graphics.BitmapFactory;
56
import android.os.Bundle;
@@ -10,49 +11,41 @@
1011

1112
import androidx.appcompat.app.AppCompatActivity;
1213

14+
import com.adrino.hdr.corehdr.Constants;
15+
import com.adrino.hdr.corehdr.CreateHDR;
16+
1317
import java.io.File;
1418
import java.io.FileNotFoundException;
1519
import java.io.FileOutputStream;
1620
import java.util.ArrayList;
1721
import java.util.List;
1822

19-
import static com.adrino.renderscript.MainActivity.SCALE_THRUSHOLD;
20-
import static com.adrino.renderscript.MainActivity.SOURCE1;
21-
import static com.adrino.renderscript.MainActivity.SOURCE2;
22-
import static com.adrino.renderscript.MainActivity.SOURCE3;
23-
2423
public class Collapse extends AppCompatActivity {
25-
ExposureFusion exposureFusion;
24+
CreateHDR createHDR;
2625
List<Bitmap> bmpImages;
2726
private static final String TAG = "Collapse";
2827
private List<Bitmap> hdrOutput;
2928
private boolean set = false;
29+
private Context context;
3030

3131
@Override
3232
protected void onCreate(final Bundle savedInstanceState) {
3333
super.onCreate(savedInstanceState);
3434
setContentView(R.layout.activity_collapse);
35-
exposureFusion = new ExposureFusion(this);
35+
createHDR = new CreateHDR(this);
36+
context = this;
3637

3738
bmpImages = new ArrayList<>();
3839

39-
bmpImages.add(BitmapFactory.decodeResource(getResources(), SOURCE1));
40-
bmpImages.add(BitmapFactory.decodeResource(getResources(), SOURCE2));
41-
bmpImages.add(BitmapFactory.decodeResource(getResources(), SOURCE3));
42-
43-
int imgWidth = bmpImages.get(0).getWidth();
44-
int imgHeight = bmpImages.get(0).getHeight();
45-
int scaledWidth = imgHeight > imgWidth ? (imgWidth * SCALE_THRUSHOLD) / imgHeight : SCALE_THRUSHOLD;
46-
int scaledHeight = imgHeight > imgWidth ? SCALE_THRUSHOLD : (imgHeight * SCALE_THRUSHOLD) / imgWidth ;
47-
for (int i = 0; i < bmpImages.size(); i++) {
48-
bmpImages.set(i, Bitmap.createScaledBitmap(bmpImages.get(i), scaledWidth, scaledHeight, false));
49-
}
40+
bmpImages.add(BitmapFactory.decodeResource(getResources(), R.drawable.sarvesh_iphon1));
41+
bmpImages.add(BitmapFactory.decodeResource(getResources(), R.drawable.sarvesh_iphone2));
42+
bmpImages.add(BitmapFactory.decodeResource(getResources(), R.drawable.sarvesh_iphone3));
5043

5144
new Thread(new Runnable() {
5245
@Override
5346
public void run() {
54-
if(!HDRFilter.MEM_BOOST) {
55-
final List<Bitmap> resultant = exposureFusion.perform(bmpImages, ExposureFusion.Actions.RESULTANT);
47+
if (!Constants.MEM_BOOST) {
48+
final List<Bitmap> resultant = new CreateHDR(context).perform(bmpImages, CreateHDR.Actions.RESULTANT);
5649

5750
runOnUiThread(new Runnable() {
5851
@Override
@@ -65,14 +58,14 @@ public void run() {
6558
});
6659
}
6760
long start = System.currentTimeMillis();
68-
hdrOutput = exposureFusion.perform(bmpImages, ExposureFusion.Actions.COLLAPSE);
61+
hdrOutput = createHDR.perform(bmpImages, CreateHDR.Actions.HDR);
6962
long end = System.currentTimeMillis();
7063

71-
Log.e(TAG, "run: Total time : "+(float)(end - start)/1000+" s");
64+
Log.e(TAG, "run: Total time : " + (float) (end - start) / 1000 + " s");
7265
runOnUiThread(new Runnable() {
7366
@Override
7467
public void run() {
75-
((ImageView)findViewById(R.id.original)).setImageBitmap(bmpImages.get(2));
68+
((ImageView) findViewById(R.id.original)).setImageBitmap(bmpImages.get(2));
7669
((ImageView) findViewById(R.id.hdr)).setImageBitmap(hdrOutput.get(0));
7770
}
7871
});
@@ -84,14 +77,13 @@ public void run() {
8477
public boolean onLongClick(View v) {
8578

8679
ImageView imgView = findViewById(R.id.expanded_image);
87-
if(!set){
88-
if(hdrOutput!=null) {
80+
if (!set) {
81+
if (hdrOutput != null) {
8982
imgView.setVisibility(View.VISIBLE);
9083
imgView.setImageBitmap(hdrOutput.get(0));
9184
set = true;
9285
}
93-
}
94-
else{
86+
} else {
9587
imgView.setVisibility(View.INVISIBLE);
9688
set = false;
9789
}
@@ -101,25 +93,25 @@ public boolean onLongClick(View v) {
10193
});
10294
}
10395

104-
private void saveBitmaps(Bitmap bitmap, String filename){
96+
private void saveBitmaps(Bitmap bitmap, String filename) {
10597
String path = Environment.getExternalStorageDirectory().toString();
10698
String directory = "HDRResult";
10799

108-
path = path + "/"+ directory;
100+
path = path + "/" + directory;
109101

110-
if(!new File(path).exists()){
111-
Log.e(TAG, "saveBitmaps: "+path );
112-
if(new File(path).mkdir()){
113-
Log.v("Directory Created :", ""+path);
102+
if (!new File(path).exists()) {
103+
Log.e(TAG, "saveBitmaps: " + path);
104+
if (new File(path).mkdir()) {
105+
Log.v("Directory Created :", "" + path);
114106

115-
try{
116-
FileOutputStream out = new FileOutputStream(path+"/"+filename);
107+
try {
108+
FileOutputStream out = new FileOutputStream(path + "/" + filename);
117109
bitmap.compress(Bitmap.CompressFormat.JPEG, 90, out);
118-
} catch (FileNotFoundException e){
110+
} catch (FileNotFoundException e) {
119111
Log.e("Cannot Save", "File not found");
120-
Log.e("path", ""+path);
112+
Log.e("path", "" + path);
121113
}
122-
} else{
114+
} else {
123115
Log.e("Directory Error", "Directory cannot be created");
124116
}
125117
}

app/src/main/java/com/adrino/renderscript/ExposureFusion.java

Lines changed: 0 additions & 170 deletions
This file was deleted.

0 commit comments

Comments
 (0)