Skip to content

Commit 4d1c40b

Browse files
committed
Fixing Color
1 parent b9743ba commit 4d1c40b

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

Sources/GraphicsColor.swift

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ public extension AndroidGraphicsColor {
255255
return Android.Graphics.Color(javaObject: __return)
256256
}
257257

258+
/*
258259
/// Return a color-int from alpha, red, green, blue components.
259260
public static func argb(alpha: Int, red: Int, green: Int, blue: Int) -> Int {
260261

@@ -276,24 +277,26 @@ public extension AndroidGraphicsColor {
276277

277278
return Int(__return)
278279
}
280+
*/
279281

280-
/**
282+
/** Custom method which receive float but internaly is using the (IIII)I method.
283+
* The original (FFFF)I just is supported over api 26.
281284
* Return a color-int from alpha, red, green, blue float components in the range [0..1].
282285
*/
283286
public static func argb(alpha: Float, red: Float, green: Float, blue: Float) -> Int {
284287

285288
var __locals = [jobject]()
286289

287290
var __args = [jvalue]( repeating: jvalue(), count: 4 )
288-
__args[0] = jvalue(f: jfloat(alpha))
289-
__args[1] = jvalue(f: jfloat(red))
290-
__args[2] = jvalue(f: jfloat(green))
291-
__args[3] = jvalue(f: jfloat(blue))
291+
__args[0] = jvalue(i: jint(Int(alpha*255)))
292+
__args[1] = jvalue(i: jint(Int(red*255)))
293+
__args[2] = jvalue(i: jint(Int(green*255)))
294+
__args[3] = jvalue(i: jint(Int(blue*255)))
292295

293296
let __return = JNIMethod.CallStaticIntMethod(className: JNICache.className,
294297
classCache: &JNICache.jniClass,
295298
methodName: "argb",
296-
methodSig: "(FFFF)I",
299+
methodSig: "(IIII)I",
297300
methodCache: &JNICache.MethodID.argb2,
298301
args: &__args,
299302
locals: &__locals)

0 commit comments

Comments
 (0)