Ich habe an einem Gaußschen Weichzeichner auf Java und libgdx gearbeitet. Es funktioniert meist ...Java, LibGDX - Gaußscher Weichzeichner Farbseparator Probleme - negativer Wert
This is the image that I am trying to blur.
Das Problem ist der Rot-Wert gleich -1 in den meisten Fällen eher als so etwas wie 255. Ich habe viele Foren gesucht und sie nicht ansprechen dieses Problem. I haben auch festgestellt, dass die meisten Menschen ARGB8888 verwenden, aber Badlogics Bibliothek hat nicht das ARGB8888-Format hat RGBA8888-Format. Ich suchte auch Websites für, wie der RGBA8888 seine Informationen in Bits speichert und ich etwas verstehe, aber nicht genug, um das Problem zu beheben.
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Pixmap;
import com.badlogic.gdx.graphics.PixmapIO;
import com.badlogic.gdx.utils.BufferUtils;
import com.badlogic.gdx.utils.ScreenUtils;
import java.awt.image.ConvolveOp;
import java.nio.ByteBuffer;
public class ScreenCapture {
public void capture(){
float output = 0;
int[] all = new int[11];
Pixmap originalPixmap = new Pixmap(Gdx.files.internal("graphics/menu/test.png"));
Pixmap pixmapVertical = new Pixmap(originalPixmap.getWidth(), originalPixmap.getHeight(), Pixmap.Format.RGBA8888);
Pixmap pixmap = new Pixmap(pixmapVertical.getWidth(), pixmapVertical.getHeight(), Pixmap.Format.RGBA8888);
for (int y = 0;y < originalPixmap.getHeight();y++){
for (int x = 0;x < originalPixmap.getWidth();x++){
for (int i = -5; i < 5; i++) {
all[i+5] = originalPixmap.getPixel(x+i, y);
}
pixmapVertical.setColor(blur(all));
pixmapVertical.drawPixel(x, y);
}
}
for (int x = 0;x < pixmapVertical.getWidth();x++){
for (int y = 0;y < pixmapVertical.getHeight();y++){
for (int i = -5; i < 5; i++) {
all[i+5] = pixmapVertical.getPixel(x, y+i);
}
pixmap.setColor(blur(all));
pixmap.drawPixel(x, y);
}
}
PixmapIO.writePNG(Gdx.files.local("screen.png"), pixmap);
originalPixmap.dispose();
pixmapVertical.dispose();
pixmap.dispose();
int rgb = 0xffffffff;
int test = ((rgb & 0xff000000) >> 24);
System.out.println(test);
}
private int blur(int[] all){
float[] weight = {0.0093f, 0.028002f, 0.065984f, 0.121703f, 0.175713f, 0.198596f, 0.175713f, 0.121703f, 0.065984f, 0.028002f, 0.0093f};
float r = 0;
float g = 0;
float b = 0;
float a = 0;
for (int i = 0; i < 11; i++){
b += (((all[i] & 0x0000ff00)>>8)*weight[i]);
r += (((all[i] & 0xff000000)>>24)*weight[i]);
g += (((all[i] & 0x00ff0000)>>16)*weight[i]);
a += (((all[i] & 0x000000ff))*weight[i]);
}
return (((int) r << 24 | (int)g << 16 | (int)b << 8 | (int)a));
}
}
Versuchen Sie, Ihre '&' nach dem Verschieben zu tun. Es scheint, das Problem ist Int ist unterzeichnet. http://ideone.com/vV1OO3 – matt