Logical operator with 0xff000000?


I want to convert image pixels from RGB to ARGB and set the alpha to 0xff。 Use an function.like
fun rgbToArgb(pixel:Int):Int{
return pixel or 0xff000000;

But it compile error,What’s can i do?


As far as i know, in kotlin , 0xff000000 is not Int anymore , it’s considered Long. so Perhaps your better off using Longs , and convert to Int or just keep them Long … You got the idea.


It is a “unsigned int valid value”, but Kotlin not support unsigned value in hex unlike java. You can transformate the value to negative equivalent value.