kopia lustrzana https://github.com/xdsopl/robot36
Removed usage of ColorUtils.blendARGB
rodzic
ba4b8bc4a5
commit
157cd71c33
|
@ -6,6 +6,8 @@ Copyright 2024 Ahmet Inan <xdsopl@gmail.com>
|
|||
|
||||
package xdsopl.robot36;
|
||||
|
||||
import android.graphics.Color;
|
||||
|
||||
public final class ColorConverter {
|
||||
|
||||
private static int clamp(int value) {
|
||||
|
@ -36,6 +38,24 @@ public final class ColorConverter {
|
|||
return 0xff000000 | (R << 16) | (G << 8) | B;
|
||||
}
|
||||
|
||||
private static int[] argb2components(int argb) {
|
||||
return new int[] { (argb >> 24) & 0xff, (argb >> 16) & 0xff, (argb >> 8) & 0xff, argb & 0xff };
|
||||
}
|
||||
|
||||
public static int blend(int argbLeft, int argbRight, float ratioOfArgbRight) {
|
||||
int[] componentsLeft = argb2components(argbLeft);
|
||||
int[] componentsRight = argb2components(argbRight);
|
||||
int[] output = new int[4];
|
||||
|
||||
ratioOfArgbRight = clamp(ratioOfArgbRight);
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
output[i] = clamp(Math.round(componentsLeft[i] * (1 - ratioOfArgbRight) + componentsRight[i] * ratioOfArgbRight));
|
||||
}
|
||||
|
||||
return Color.argb(output[0], output[1], output[2], output[3]);
|
||||
}
|
||||
|
||||
public static int GRAY(float level) {
|
||||
return 0xff000000 | 0x00010101 * compress(level);
|
||||
}
|
||||
|
|
|
@ -44,7 +44,6 @@ import androidx.appcompat.app.AppCompatDelegate;
|
|||
import androidx.appcompat.widget.ShareActionProvider;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.core.graphics.ColorUtils;
|
||||
import androidx.core.graphics.Insets;
|
||||
import androidx.core.os.LocaleListCompat;
|
||||
import androidx.core.view.MenuItemCompat;
|
||||
|
@ -238,7 +237,7 @@ public class MainActivity extends AppCompatActivity {
|
|||
for (int freq: markerFrequencies) {
|
||||
int marker = freq / binWidthHz - lowestBin;
|
||||
waterfallPlotBuffer.pixels[line + marker - 1] = Color.BLACK;
|
||||
waterfallPlotBuffer.pixels[line + marker] = ColorUtils.blendARGB(waterfallPlotBuffer.pixels[line + marker], Color.GREEN, 0.8f);
|
||||
waterfallPlotBuffer.pixels[line + marker] = ColorConverter.blend(waterfallPlotBuffer.pixels[line + marker], Color.GREEN, 0.8f);
|
||||
waterfallPlotBuffer.pixels[line + marker + 1] = Color.BLACK;
|
||||
}
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue