Skip to content
This repository has been archived by the owner on Sep 2, 2023. It is now read-only.

Commit

Permalink
Optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
Nalin-Angrish committed Oct 15, 2020
1 parent 5601228 commit 115bb5f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
1 change: 0 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ android {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.activity:activity:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.2'
implementation 'com.google.android.material:material:1.2.1'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
Expand Down
12 changes: 6 additions & 6 deletions app/src/main/java/com/nalinstudios/iscan/internal/Statics.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
public class Statics {
/** The characters which can be used to generate a random string*/
private final static String chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
/** The width of the page*/
final private static int PageWidth = 700;

/**
* A function to generate a random string
Expand Down Expand Up @@ -67,16 +69,16 @@ public static void createPdf(Application app, String name) throws IOException, D
}

Document doc = new Document(PageSize.A4,0,0,0,0);
PdfWriter writer = PdfWriter.getInstance(doc, new FileOutputStream(pdf));
PdfWriter.getInstance(doc, new FileOutputStream(pdf));
doc.open();
doc.addAuthor("IScan - The Document Scanner");
for (Bitmap image : images){
float pw = PageSize.A4.getWidth();
float pw = PageWidth;
float iw = image.getWidth();
float ih = image.getHeight();
float rat = pw/iw;
float ph = rat*ih;
Bitmap page = Bitmap.createScaledBitmap(image,(int)pw,(int)ph,true); // scale the bitmap so that the page width is standard (of an A4 size)
Bitmap page = Bitmap.createScaledBitmap(image,(int)pw,(int)ph,true); // scale the bitmap so that the page width is standard (it looks clean and good)

doc.setPageSize(new Rectangle(pw, ph));
doc.newPage();
Expand All @@ -86,8 +88,6 @@ public static void createPdf(Application app, String name) throws IOException, D


doc.close();
writer.flush();
writer.close();
File thumbnailFile = getThumbnail(app);
File dataStorage = new File(pdfFolder, ".data-internal");
if (!dataStorage.exists()){System.out.println(dataStorage.mkdir());}
Expand All @@ -104,7 +104,7 @@ public static void createPdf(Application app, String name) throws IOException, D
* @param image The image to be decoded into byte array.
* @return The byte array for the image.
*/
public static byte[] toByteArray(Bitmap image){
private static byte[] toByteArray(Bitmap image){
ByteArrayOutputStream baos = new ByteArrayOutputStream();
image.compress(Bitmap.CompressFormat.JPEG, 100, baos);
return baos.toByteArray();
Expand Down

0 comments on commit 115bb5f

Please sign in to comment.