forked from pierx/Samsung_SPR_BMP_Converter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 10a8547
Showing
23 changed files
with
633 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
*.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 |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# SPR Converter | ||
|
||
How to convert Samsung .spr/.bmp to .png | ||
|
||
Instruction | ||
1. Place all the .spr files inside the src/main/res/drawable folder inside the project | ||
2. Replace all the .spr extension to .bmp (Tip: Use BulkRenameUtility software and use extension) | ||
3. Build the app with Android Studio or Gradle cli | ||
4. Install the app apk on Samsung devices | ||
5. Press Convert now and check out the result on convert folder on storage | ||
|
||
Credits to dgadelha @xda | ||
https://forum.xda-developers.com/showpost.php?p=77683386&postcount=105 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
apply plugin: 'com.android.application' | ||
|
||
android { | ||
compileSdkVersion 28 | ||
defaultConfig { | ||
applicationId "com.convert.spr" | ||
minSdkVersion 24 | ||
targetSdkVersion 28 | ||
versionCode 1 | ||
versionName "1.0" | ||
} | ||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
package="com.convert.spr"> | ||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> | ||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> | ||
|
||
<application | ||
android:icon="@android:drawable/sym_def_app_icon" | ||
android:label="Convert SPR" | ||
android:theme="@android:style/Theme.DeviceDefault" | ||
tools:ignore="GoogleAppIndexingWarning" | ||
android:allowBackup="false"> | ||
<activity android:name=".MainActivity"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
</manifest> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
package com.convert.spr; | ||
|
||
import android.Manifest; | ||
import android.app.Activity; | ||
import android.graphics.Bitmap; | ||
import android.graphics.Canvas; | ||
import android.graphics.drawable.BitmapDrawable; | ||
import android.graphics.drawable.Drawable; | ||
import android.os.Bundle; | ||
import android.os.Environment; | ||
import android.util.Log; | ||
import android.view.View; | ||
import android.view.View.OnClickListener; | ||
import android.widget.Button; | ||
import android.widget.ImageView; | ||
import android.widget.Toast; | ||
|
||
import java.io.File; | ||
import java.io.FileOutputStream; | ||
import java.io.IOException; | ||
import java.lang.reflect.Field; | ||
|
||
public class MainActivity extends Activity { | ||
Button button; | ||
ImageView image; | ||
|
||
public static Bitmap drawableToBitmap(Drawable drawable) { | ||
Bitmap bitmap; | ||
|
||
if (drawable instanceof BitmapDrawable) { | ||
BitmapDrawable bitmapDrawable = (BitmapDrawable) drawable; | ||
if (bitmapDrawable.getBitmap() != null) { | ||
return bitmapDrawable.getBitmap(); | ||
} | ||
} | ||
|
||
if (drawable.getIntrinsicWidth() <= 0 || drawable.getIntrinsicHeight() <= 0) { | ||
bitmap = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888); // Single color bitmap will be created of 1x1 pixel | ||
} else { | ||
bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888); | ||
} | ||
|
||
Canvas canvas = new Canvas(bitmap); | ||
drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight()); | ||
drawable.draw(canvas); | ||
return bitmap; | ||
} | ||
|
||
/* | ||
* Bitmap.CompressFormat can be PNG,JPEG or WEBP. | ||
* | ||
* quality goes from 1 to 100. (Percentage). | ||
* | ||
* dir you can get from many places like Environment.getExternalStorageDirectory() or mContext.getFilesDir() | ||
* depending on where you want to save the image. | ||
*/ | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_main); | ||
requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 1); | ||
addListenerOnButton(); | ||
} | ||
|
||
public void saveBitmapToFile(File dir, String fileName, Bitmap bm, | ||
Bitmap.CompressFormat format, int quality) { | ||
if (bm == null) { | ||
Log.e("spr", "bm is null"); | ||
return; | ||
} | ||
File imageFile = new File(dir, fileName); | ||
|
||
FileOutputStream fos = null; | ||
try { | ||
fos = new FileOutputStream(imageFile); | ||
|
||
bm.compress(format, quality, fos); | ||
|
||
fos.close(); | ||
|
||
} catch (IOException e) { | ||
Log.e("app", e.getMessage()); | ||
if (fos != null) { | ||
try { | ||
fos.close(); | ||
} catch (IOException e1) { | ||
e1.printStackTrace(); | ||
} | ||
} | ||
} | ||
} | ||
|
||
public void addListenerOnButton() { | ||
|
||
image = findViewById(R.id.imageView1); | ||
button = findViewById(R.id.btnChangeImage); | ||
button.setOnClickListener(new OnClickListener() { | ||
|
||
@Override | ||
public void onClick(View arg0) { | ||
/* Loop through all drawables to convert them */ | ||
final R.drawable drawableResources = new R.drawable(); | ||
final Class<R.drawable> c = R.drawable.class; | ||
final Field[] fields = c.getDeclaredFields(); | ||
|
||
for (Field field : fields) { | ||
Log.i("spr", "Dumping: " + field); | ||
final int resourceId; | ||
try { | ||
resourceId = field.getInt(drawableResources); | ||
} catch (Exception e) { | ||
continue; | ||
} | ||
/* make use of resourceId for accessing Drawables here */ | ||
@SuppressWarnings("deprecation") Drawable d = getResources().getDrawable(resourceId); | ||
image.setImageDrawable(d); | ||
Bitmap bm = drawableToBitmap(d); | ||
// Bitmap bm = BitmapFactory.decodeResource(image.getResources(), resourceId); | ||
String name = image.getResources().getResourceEntryName(resourceId); | ||
|
||
|
||
File dir = new File(Environment.getExternalStorageDirectory() + File.separator + "convert"); | ||
|
||
boolean doSave = true; | ||
if (!dir.exists()) { | ||
doSave = dir.mkdirs(); | ||
} | ||
|
||
if (doSave) { | ||
saveBitmapToFile(dir, name + ".png", bm, Bitmap.CompressFormat.PNG, 100); | ||
Toast.makeText(MainActivity.this, "Done. \nCheck out the convert folder on storage", Toast.LENGTH_SHORT).show(); | ||
} else { | ||
Log.e("app", "Couldn't create target directory."); | ||
} | ||
} | ||
} | ||
|
||
}); | ||
} | ||
} |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="fill_parent" | ||
android:layout_height="fill_parent" | ||
android:gravity="center_horizontal|center_vertical" | ||
android:orientation="vertical"> | ||
|
||
<ImageView | ||
android:id="@+id/imageView1" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" /> | ||
|
||
<Button | ||
android:id="@+id/btnChangeImage" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:gravity="center|center_horizontal|fill_horizontal|center_vertical" | ||
android:text="@string/button"/> | ||
</LinearLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<string name="button">Convert Now</string> | ||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Top-level build file where you can add configuration options common to all sub-projects/modules. | ||
|
||
buildscript { | ||
repositories { | ||
google() | ||
jcenter() | ||
|
||
} | ||
dependencies { | ||
classpath 'com.android.tools.build:gradle:3.3.2' | ||
|
||
// NOTE: Do not place your application dependencies here; they belong | ||
// in the individual module build.gradle files | ||
} | ||
} | ||
|
||
allprojects { | ||
repositories { | ||
google() | ||
jcenter() | ||
|
||
} | ||
} | ||
|
||
task clean(type: Delete) { | ||
delete rootProject.buildDir | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Project-wide Gradle settings. | ||
|
||
# IDE (e.g. Android Studio) users: | ||
# Gradle settings configured through the IDE *will override* | ||
# any settings specified in this file. | ||
|
||
# For more details on how to configure your build environment visit | ||
# http://www.gradle.org/docs/current/userguide/build_environment.html | ||
|
||
# Specifies the JVM arguments used for the daemon process. | ||
# The setting is particularly useful for tweaking memory settings. | ||
# Default value: -Xmx10248m -XX:MaxPermSize=256m | ||
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 | ||
|
||
# When configured, Gradle will run in incubating parallel mode. | ||
# This option should only be used with decoupled projects. More details, visit | ||
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects | ||
# org.gradle.parallel=true | ||
# android.enableR8 = true |
Binary file not shown.
Oops, something went wrong.