Merge pull request #11 from LeoDJ/master
fix #10 alpha color issue for pixelwar
This commit is contained in:
commit
d698dca2ab
2 changed files with 7 additions and 6 deletions
|
|
@ -151,8 +151,8 @@ public class NetCanvas implements ComponentListener, KeyListener,
|
||||||
final BufferedImage img = pxBuffer;
|
final BufferedImage img = pxBuffer;
|
||||||
|
|
||||||
if (x >= 0 && x < img.getWidth() && y >= 0 && y < img.getHeight()) {
|
if (x >= 0 && x < img.getWidth() && y >= 0 && y < img.getHeight()) {
|
||||||
final int alpha = (argb >>> 24) % 256;
|
final int alpha = argb & 0xff;
|
||||||
int rgb = argb & 0xffffff;
|
int rgb = (argb & 0xffffff00) >>> 8;
|
||||||
|
|
||||||
if (alpha < 1) {
|
if (alpha < 1) {
|
||||||
return;
|
return;
|
||||||
|
|
@ -166,9 +166,9 @@ public class NetCanvas implements ComponentListener, KeyListener,
|
||||||
g = ((target >>> 8) & 0xff) * (255 - alpha);
|
g = ((target >>> 8) & 0xff) * (255 - alpha);
|
||||||
b = ((target >>> 0) & 0xff) * (255 - alpha);
|
b = ((target >>> 0) & 0xff) * (255 - alpha);
|
||||||
|
|
||||||
r += ((argb >>> 16) & 0xff) * alpha;
|
r += ((rgb >>> 16) & 0xff) * alpha;
|
||||||
g += ((argb >>> 8) & 0xff) * alpha;
|
g += ((rgb >>> 8) & 0xff) * alpha;
|
||||||
b += ((argb >>> 0) & 0xff) * alpha;
|
b += ((rgb >>> 0) & 0xff) * alpha;
|
||||||
|
|
||||||
rgb = 0xff << 24;
|
rgb = 0xff << 24;
|
||||||
rgb += (r / 255) << 16;
|
rgb += (r / 255) << 16;
|
||||||
|
|
|
||||||
|
|
@ -177,7 +177,8 @@ public class PixelClientHandler extends SimpleChannelInboundHandler<String> {
|
||||||
final int y = Integer.parseInt(args[1]);
|
final int y = Integer.parseInt(args[1]);
|
||||||
int color = (int) Long.parseLong(args[2], 16);
|
int color = (int) Long.parseLong(args[2], 16);
|
||||||
if (args[2].length() == 6) {
|
if (args[2].length() == 6) {
|
||||||
color += 0xff000000;
|
color = color << 8;
|
||||||
|
color += 0x000000ff;
|
||||||
}
|
}
|
||||||
label.setPos(x, y);
|
label.setPos(x, y);
|
||||||
canvas.setPixel(x, y, color);
|
canvas.setPixel(x, y, color);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue