Created
June 6, 2016 13:33
-
-
Save egonny/b09628cc94439a0ac7d08f7d9b04f36c to your computer and use it in GitHub Desktop.
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
package me.egon.testapplication; | |
import android.graphics.Bitmap; | |
import android.os.Bundle; | |
import android.support.v7.app.AppCompatActivity; | |
import android.widget.ImageView; | |
import java.nio.IntBuffer; | |
public class MainActivity extends AppCompatActivity { | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
String decompressed = LZString.decompressFromUTF16("8أ㲶\u2B84ᾘ抒䠧⁀垠ྣ㑎懣⚱䶖ⵘ䂈䀢惍Ḡ䝰炳㶽摴⁘W㹜擰Ě䓆ᐡ㸠ਅ乼㣎༾䦅娇垢歲\u2E63\u2E7C晃ሀ⛴\u0CB4婊㨤梡疱峤⼯\u1CAEǶ疅䭂䯍⎨ࠠ "); | |
char[] pixels = decompressed.toCharArray(); | |
Bitmap image = Bitmap.createBitmap(16, 16, Bitmap.Config.ARGB_8888); | |
int[] rgbs = new int[256]; | |
for (int x = 0; x < 16; x++) { | |
for (int y = 0; y < 16; y++) { | |
rgbs[y * 16 + x] = charToRGB(pixels[y * 16 + x]); | |
} | |
} | |
image.copyPixelsFromBuffer(IntBuffer.wrap(rgbs)); | |
ImageView frame = (ImageView) findViewById(R.id.bitmapframe); | |
if (frame != null) { | |
frame.setImageBitmap(image); | |
} | |
} | |
public static int charToRGB(char c) { | |
if (c == 0) return 0; | |
int r, g, b; | |
int rgb = ((int) c) - 1; | |
r = (int) Math.round(rgb % 10 * 25.5); | |
g = (int) Math.round((rgb / 10) % 10 * 25.5); | |
b = (int) Math.round((rgb / 100) % 10 * 25.5); | |
return 0xff << 24 | b << 16 | g << 8 | r; // use ABGR instead of ARGB to handle endianness (I think?) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment