Skip to content

Instantly share code, notes, and snippets.

View LiewJunTung's full-sized avatar

Liew Jun Tung LiewJunTung

View GitHub Profile
import 'dart:async';
Future<String> networkCallGetString() async {
await Future.delayed(Duration(seconds: 5));
return "Simulated Network Call";
}
doNetworkCall() async {
var result = networkCallGetString();
print(result);
extension NumberParsing on String {
int parseInt() {
return int.parse(this);
}
double parseDouble() {
return double.parse(this);
}
}
package com.netvirta.ci_image_resize_plugin
import javax.imageio.ImageIO
import java.awt.image.BufferedImage;
import java.io.File
import javax.imageio.stream.ImageInputStream
class CiImageResize {
fun resize(inputJpgFilePath: String, outputJpgFilePath: String, outputWidth: Int, outputHeight: Int) {
@LiewJunTung
LiewJunTung / build.gradle.kts
Created July 29, 2019 16:24
Gradle plugin tutorial
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
kotlin("jvm") version "1.3.41"
`java-gradle-plugin`
id("com.gradle.plugin-publish") version "0.10.0"
}
pluginBundle {
website = "<substitute your project website>"
abstract class SymbolicLinkTask : DefaultTask() {
var actualFilePath: String? = null
var symbolicDirPath: String? = null
var rename: String? = null
@TaskAction
fun link() {
val aPath = actualFilePath ?: throw Exception("actualPath not set")
val sPath = symbolicDirPath ?: throw Exception("symbolicPath not set")
fun rotateBitmap(context: Context, bitmap: Bitmap): Bitmap{
val rs = RenderScript.create(context)
val allocation = Allocation.createFromBitmap(rs, bitmap)
val rotated = Allocation.createTyped(rs, Type.createXY(rs, Element.RGBA_8888(rs), bitmap.height, bitmap.width))
ScriptC_rotator(rs).apply {
_inImage = allocation
_inHeight = bitmap.height
_inWidth = bitmap.width
forEach_rotate_270_clockwise(rotated, rotated)
package com.liewjuntung.cameraxfacetracking
import android.content.pm.PackageManager
import android.graphics.Bitmap
import android.os.Bundle
import android.os.Handler
import android.os.HandlerThread
import android.renderscript.RenderScript
import android.util.Rational
import android.util.Size
@LiewJunTung
LiewJunTung / YuvToRgb.kt
Last active July 9, 2019 17:27
Best performance
class RsYuvToRgb(private val rs: RenderScript) {
private var mOutputAllocation: Allocation? = null
private var mInputAllocation: Allocation? = null
private val rsYuvToRgb = ScriptIntrinsicYuvToRGB.create(rs, Element.U8_4(rs))
private var yArray: ByteArray? = null
private var uArray: ByteArray? = null
private var vArray: ByteArray? = null
class RsYuvToRgb(val rs: RenderScript) {
private var rotateAllocation: Allocation? = null
private var mOutputAllocation: Allocation? = null
private var mInputAllocation: Allocation? = null
private val rsYuvToRgb = ScriptIntrinsicYuvToRGB.create(rs, Element.U8_4(rs))
private var yArray: ByteArray? = null
private var uArray: ByteArray? = null