Skip to content

Commit

Permalink
1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ShubhadeepKarmakar committed Mar 29, 2023
2 parents 249a2bd + f7f34e9 commit c4c472a
Show file tree
Hide file tree
Showing 65 changed files with 2,184 additions and 3 deletions.
15 changes: 15 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
/build
/captures
.externalNativeBuild
.cxx
local.properties
6 changes: 6 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
47 changes: 47 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
}

android {
namespace 'com.example.ai_background_eraser'
compileSdk 33

defaultConfig {
applicationId "com.example.ai_background_eraser"
minSdk 24
targetSdk 33
versionCode 1
versionName "1.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
}

dependencies {

implementation 'androidx.core:core-ktx:1.9.0'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.8.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation project(path: ':autobackgroundremover')
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
//gestureView
implementation 'com.alexvasilkov:gesture-views:2.8.3'
}
22 changes: 22 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.example.ai_background_eraser

import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4

import org.junit.Test
import org.junit.runner.RunWith

import org.junit.Assert.*

/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("com.example.ai_background_eraser", appContext.packageName)
}
}
31 changes: 31 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/Theme.AIBackgroundEraser"
tools:targetApi="31">
<activity
android:name=".MainActivity"
android:screenOrientation="portrait"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<!-- <activity android:name="com.theartofdev.edmodo.cropper.CropImageActivity"-->
<!-- android:theme="@style/Base.Theme.AppCompat"/>-->
</application>

</manifest>
Binary file added app/src/main/ic_launcher-playstore.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package com.example.ai_background_eraser;

import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;

public class BitmapUtility {

static Bitmap getResizedBitmap(Bitmap bitmap, int width, int height) {
Bitmap background = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);

float originalWidth = bitmap.getWidth();
float originalHeight = bitmap.getHeight();

Canvas canvas = new Canvas(background);

float scale = width / originalWidth;

float xTranslation = 0.0f;
float yTranslation = (height - originalHeight * scale) / 2.0f;

Matrix transformation = new Matrix();
transformation.postTranslate(xTranslation, yTranslation);
transformation.preScale(scale, scale);

Paint paint = new Paint();
paint.setFilterBitmap(true);

canvas.drawBitmap(bitmap, transformation, paint);

return background;
}

static Bitmap getBorderedBitmap(Bitmap image, int borderColor, int borderSize) {

// Creating a canvas with an empty bitmap, this is the bitmap that gonna store the final canvas changes
Bitmap finalImage = Bitmap.createBitmap(image.getWidth(), image.getHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(finalImage);

// Make a smaller copy of the image to draw on top of original
Bitmap imageCopy = Bitmap.createScaledBitmap(image, image.getWidth() - borderSize, image.getHeight() - borderSize, true);

// Let's draw the bigger image using a white paint brush
Paint paint = new Paint();
paint.setColorFilter(new PorterDuffColorFilter(borderColor, PorterDuff.Mode.SRC_ATOP));
canvas.drawBitmap(image, 0, 0, paint);

int width = image.getWidth();
int height = image.getHeight();
float centerX = (width - imageCopy.getWidth()) * 0.5f;
float centerY = (height - imageCopy.getHeight()) * 0.5f;
// Now let's draw the original image on top of the white image, passing a null paint because we want to keep it original
canvas.drawBitmap(imageCopy, centerX, centerY, null);

// Returning the image with the final results
return finalImage;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
package com.example.ai_background_eraser

import android.graphics.*
import android.graphics.drawable.Drawable

//import android.support.annotation.NonNull;
//import android.support.annotation.Nullable;


class CheckerboardDrawable private constructor(builder: Builder) :
Drawable() {
private val paint = Paint(Paint.ANTI_ALIAS_FLAG)
private val size: Int
private val colorOdd: Int
private val colorEven: Int

init {
size = builder.size
colorOdd = builder.colorOdd
colorEven = builder.colorEven
configurePaint()
}

private fun configurePaint() {
val bitmap = Bitmap.createBitmap(size * 2, size * 2, Bitmap.Config.ARGB_8888)
val bitmapPaint = Paint(Paint.ANTI_ALIAS_FLAG)
bitmapPaint.style = Paint.Style.FILL
val canvas = Canvas(bitmap)
val rect = Rect(0, 0, size, size)
bitmapPaint.color = colorOdd
canvas.drawRect(rect, bitmapPaint)
rect.offset(size, size)
canvas.drawRect(rect, bitmapPaint)
bitmapPaint.color = colorEven
rect.offset(-size, 0)
canvas.drawRect(rect, bitmapPaint)
rect.offset(size, -size)
canvas.drawRect(rect, bitmapPaint)
paint.shader =
BitmapShader(bitmap, Shader.TileMode.REPEAT, Shader.TileMode.REPEAT)
}

override fun draw(canvas: Canvas) {
canvas.drawPaint(paint)
}

override fun setAlpha(alpha: Int) {
paint.alpha = alpha
}

override fun setColorFilter(colorFilter: ColorFilter?) {
paint.colorFilter = colorFilter
}

override fun getOpacity(): Int {
return PixelFormat.OPAQUE
}

class Builder {
var size = 40
var colorOdd = -0x3d3d3e
var colorEven = -0xc0c0d
fun size(size: Int): Builder {
this.size = size
return this
}

fun colorOdd(color: Int): Builder {
colorOdd = color
return this
}

fun colorEven(color: Int): Builder {
colorEven = color
return this
}

fun build(): CheckerboardDrawable {
return CheckerboardDrawable(this)
}
}

companion object {
fun create(): CheckerboardDrawable {
return CheckerboardDrawable(Builder())
}
}
}
Loading

0 comments on commit c4c472a

Please sign in to comment.