Hier ist mein Code:Java Bitmap Farbton ändern
public static Bitmap processing(Bitmap src, float hue) {
int width = src.getWidth();
int height = src.getHeight();
Bitmap bitmap = Bitmap.createBitmap(width, height, src.getConfig());
for(int x = 0; x < width; x++) {
for (int y = 0; y < height; y++) {
int newPixel = hueChange(src.getPixel(x, y), hue);
bitmap.setPixel(x, y, newPixel);
}
}
return bitmap;
}
private static int hueChange(int startpixel, float hue) {
float[] hsv = new float[3]; //array to store HSV values
Color.colorToHSV(startpixel,hsv); //get original HSV values of pixel
hsv[0]=hsv[0]+hue; //add the shift to the HUE of HSV array
hsv[0]=hsv[0]%360; //confines hue to values:[0,360]
return Color.HSVToColor(Color.alpha(startpixel),hsv);
}
Problem ist: processing
nimmt bis 3300ms wenn Größe src Bitmap 480x480 ist. Und es ist zu lang für mich.
Was ist der schnellste Weg, es zu tun?
Fertig!
Der schnellste Weg ist OpenCV mit NDK zu verwenden.
nicht sicher, welche Bildtransformationen Sie zu tun versuchen zu. Einige können durch das vorhandene Renderscript ScriptInstrinstics bereitgestellt werden, Sie könnten es in Renderscript schreiben oder Sie können nach OpenGL-basierten Bildverarbeitungsbibliotheken suchen. –
siehe 'Bitmap # createBitmap (int [] Farben, int width, int height, Bitmap.Config config)' oder ähnliche 'Bitmap # createBitmap' Methoden – pskink
kein Glück? es funktioniert nicht? Gibt eine Null zurück? eine leere 'Bitmap'? – pskink