当前位置: 首页>>代码示例>>Java>>正文


Java Pixmap.drawPixel方法代码示例

本文整理汇总了Java中com.badlogic.gdx.graphics.Pixmap.drawPixel方法的典型用法代码示例。如果您正苦于以下问题:Java Pixmap.drawPixel方法的具体用法?Java Pixmap.drawPixel怎么用?Java Pixmap.drawPixel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.badlogic.gdx.graphics.Pixmap的用法示例。


在下文中一共展示了Pixmap.drawPixel方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: generateScreenshot

import com.badlogic.gdx.graphics.Pixmap; //导入方法依赖的package包/类
public Pixmap generateScreenshot(ParticleSystem particleSystem, Player player) {
    final float cam_width = camera.getCameraWidth();
    final float cam_height = camera.getCameraHeight();
    final int current_x = camera.getCameraX();
    final int current_y = camera.getCameraY();
    final Pixmap screen_shot = new Pixmap((int) cam_width, (int) cam_height, Pixmap.Format.RGB888);

    for (int i = current_x; i < current_x + cam_width; i++) {
        for (int j = current_y; j < current_y + cam_height; j++) {
            Particle current_particle = particleSystem.getParticle(i, j);

            if (current_particle != null) {
                screen_shot.setColor(current_particle.getProperties().getColor());
                screen_shot.drawPixel(i - current_x, ((int) cam_height - 1) - (j - current_y));
            }
        }
    }

    return screen_shot;
}
 
开发者ID:treeman1111,项目名称:Particles,代码行数:21,代码来源:DisplayManager.java

示例2: createHighlightingGraphic

import com.badlogic.gdx.graphics.Pixmap; //导入方法依赖的package包/类
private Texture createHighlightingGraphic(TextureRegion textureRegion)
{
	TextureData textureData = textureRegion.getTexture().getTextureData();
	textureData.prepare();
	Pixmap sourcePixmap = textureData.consumePixmap();
	Pixmap destinationPixmap = new Pixmap(textureRegion.getRegionWidth(), textureRegion.getRegionHeight(), Format.RGBA8888);
	Color color = new Color();

	for (int x = 0; x < textureRegion.getRegionWidth(); x++)
	{
		for (int y = 0; y < textureRegion.getRegionHeight(); y++)
		{
			int colorInt = sourcePixmap.getPixel(textureRegion.getRegionX() + x, textureRegion.getRegionY() + y);
			Color.rgba8888ToColor(color, colorInt);
			destinationPixmap.setColor(1.0f, 1f, 1.0f, 1);
			if (color.a > 0.004f)
				destinationPixmap.drawPixel(x, y);
		}
	}
	Texture result = new Texture(destinationPixmap);
	textureData.disposePixmap();
	destinationPixmap.dispose();
	return result;
}
 
开发者ID:MMORPG-Prototype,项目名称:MMORPG_Prototype,代码行数:25,代码来源:GameObjectHighlightGraphic.java

示例3: gaussianPixmap

import com.badlogic.gdx.graphics.Pixmap; //导入方法依赖的package包/类
private static void gaussianPixmap(Pixmap in, Pixmap out, double[][] gwm, int gaussianRadius) {
	Color inColor = new Color();
	Color outColor = new Color();

	int offsetX = (in.getWidth() - out.getWidth()) / 2;
	int offsetY = (in.getHeight() - out.getHeight()) / 2;

	int width = out.getWidth();
	int height = out.height();
	for (int x = 0; x < width; x++, width = out.getWidth()) {
		for (int y = 0; y < height; y++, height = out.height()) {
			outColor.set(0, 0, 0, 0);

			for (int ox = -gaussianRadius; ox <= gaussianRadius; ox++) {
				for (int oy = -gaussianRadius; oy <= gaussianRadius; oy++) {
					int pixel = in.getPixel(x + ox + offsetX, y + oy + offsetY);
					inColor.set(pixel);
					double d = gwm[ox + gaussianRadius][oy + gaussianRadius];
					outColor.r += inColor.r * d;
					outColor.g += inColor.g * d;
					outColor.b += inColor.b * d;
					outColor.a += inColor.a * d;
				}
			}

			out.drawPixel(x, y, Color.rgba8888(outColor.clamp()));
		}
	}
}
 
开发者ID:RedTroop,项目名称:Cubes_2,代码行数:30,代码来源:AOTextureGenerator.java

示例4: testRemovedPixmapField

import com.badlogic.gdx.graphics.Pixmap; //导入方法依赖的package包/类
public void testRemovedPixmapField(){
    GraphHeader.currentReadWriteVersion = 0;

    TestClass object = new TestClass();
    object.someInt = randInt();
    object.someFloat = randFloat();
    object.point = new GridPoint2(randInt(), randInt());
    object.color = new Color(Color.CYAN);
    object.smallTestClass = new SmallTestClass();
    object.smallTestClass.someValue = randInt();

    Pixmap pixmap = new Pixmap(20, 24, Pixmap.Format.RGBA8888);
    for (int i = 0; i < pixmap.getWidth(); i++) {
        for (int j = 0; j < pixmap.getHeight(); j++) {
            pixmap.drawPixel(i, j, randInt());
        }
    }
    object.smallTestClass.somePixmap = pixmap;

    kryo.register(SmallTestClass.class);
    kryo.register(TestClass.class);

    GraphHeader<TestClass> graphHeader = new GraphHeader<TestClass>();
    graphHeader.data = object;

    GraphHeader.currentReadWriteVersion = 0;
    byte[] written = write(graphHeader);

    GraphHeader.currentReadWriteVersion = 1;
    GraphHeader<TestClass> returned = read(written, GraphHeader.class);
    assertTrue(equals(graphHeader, returned));
    assertTrue(returned.data.smallTestClass.somePixmap == null);
}
 
开发者ID:CypherCove,项目名称:gdx-cclibs,代码行数:34,代码来源:GraphHeaderTest.java

示例5: blurHorizontal

import com.badlogic.gdx.graphics.Pixmap; //导入方法依赖的package包/类
private static void blurHorizontal(Pixmap src, Pixmap dst, int radius) {
    for (int i = 0; i < src.getWidth(); i++) {
        for (int j = 0; j < src.getHeight(); j++) {
            int r = 0;
            int g = 0;
            int b = 0;
            int count = 0;

            for (int x = i - radius; x <= i + radius; x++) {
                if (x < 0 || x > src.getWidth()) {
                    continue;
                }

                int current = src.getPixel(x, j) >> 8; // dump the alpha value
                b += (current & 0xff);
                current >>= 8;
                g += (current & 0xff);
                current >>= 8;
                r += (current & 0xff);

                count++;
            }

            r /= count;
            g /= count;
            b /= count;

            dst.drawPixel(i, j, getRGB(r, g, b));
        }
    }
}
 
开发者ID:treeman1111,项目名称:Particles,代码行数:32,代码来源:BoxBlur.java

示例6: blurVertical

import com.badlogic.gdx.graphics.Pixmap; //导入方法依赖的package包/类
private static void blurVertical(Pixmap src, Pixmap dst, int radius) {
    for (int i = 0; i < src.getWidth(); i++) {
        for (int j = 0; j < src.getHeight(); j++) {
            int r = 0;
            int g = 0;
            int b = 0;
            int count = 0;

            for (int y = j - radius; y <= j + radius; y++) {
                if (y < 0 || y >= src.getHeight()) {
                    continue;
                }

                int current = src.getPixel(i, y) >> 8; // no alpha needed
                b += (current & 0xff);
                current >>= 8;
                g += (current & 0xff);
                current >>= 8;
                r += (current & 0xff);

                count++;
            }

            r /= count;
            g /= count;
            b /= count;

            dst.drawPixel(i, j, getRGB(r, g, b));
        }
    }
}
 
开发者ID:treeman1111,项目名称:Particles,代码行数:32,代码来源:BoxBlur.java

示例7: gaussianPixmap

import com.badlogic.gdx.graphics.Pixmap; //导入方法依赖的package包/类
private static void gaussianPixmap(Pixmap in, Pixmap out, double[][] gwm, int gaussianRadius) {
  Color inColor = new Color();
  Color outColor = new Color();

  int offsetX = (in.getWidth() - out.getWidth()) / 2;
  int offsetY = (in.getHeight() - out.getHeight()) / 2;

  for (int x = 0; x < out.getWidth(); x++) {
    for (int y = 0; y < out.getHeight(); y++) {
      outColor.set(0, 0, 0, 0);

      for (int ox = -gaussianRadius; ox <= gaussianRadius; ox++) {
        for (int oy = -gaussianRadius; oy <= gaussianRadius; oy++) {
          int pixel = in.getPixel(x + ox + offsetX, y + oy + offsetY);
          inColor.set(pixel);
          double d = gwm[ox + gaussianRadius][oy + gaussianRadius];
          outColor.r += inColor.r * d;
          outColor.g += inColor.g * d;
          outColor.b += inColor.b * d;
          outColor.a += inColor.a * d;
        }
      }

      out.drawPixel(x, y, Color.rgba8888(outColor.clamp()));
    }
  }
}
 
开发者ID:RedTroop,项目名称:Cubes,代码行数:28,代码来源:AOTextureGenerator.java

示例8: createTexture

import com.badlogic.gdx.graphics.Pixmap; //导入方法依赖的package包/类
private static GdxTexture createTexture(int[] colors) {
	final Pixmap pixmap = new Pixmap( colors.length, 1, Pixmap.Format.RGBA8888 );
	for (int i=0; i < colors.length; i++) {
		final int color = colors[i];
		pixmap.drawPixel(i, 0, (color << 8) | (color >>> 24));
	}
	return new GdxTexture(pixmap);
}
 
开发者ID:kurtyu,项目名称:PixelDungeonTC,代码行数:9,代码来源:Gradient.java

示例9: testGraphics

import com.badlogic.gdx.graphics.Pixmap; //导入方法依赖的package包/类
public void testGraphics(){
    Object[] objects = new Object[5];

    objects[0] = new Color(random.nextFloat(), random.nextFloat(), random.nextFloat(), random.nextFloat());

    OrthographicCamera orthographicCamera = new OrthographicCamera();
    orthographicCamera.position.set(randFloat(), randFloat(), randFloat());
    orthographicCamera.viewportWidth = random.nextInt(1000);
    orthographicCamera.viewportHeight = random.nextInt(1000);
    orthographicCamera.zoom = random.nextFloat() * random.nextInt(3);
    orthographicCamera.near = 0.014f;
    orthographicCamera.far = 5000.35f;
    orthographicCamera.up.rotateRad(new Vector3(randFloat(), randFloat(), randFloat()).nor(), randFloat());
    orthographicCamera.update();
    objects[1] = orthographicCamera;

    PerspectiveCamera perspectiveCamera = new PerspectiveCamera();
    perspectiveCamera.position.set(randFloat(), randFloat(), randFloat());
    perspectiveCamera.viewportWidth = random.nextInt(1000);
    perspectiveCamera.viewportHeight = random.nextInt(1000);
    perspectiveCamera.fieldOfView = (random.nextFloat() * 0.5f + 0.5f) * 60;
    perspectiveCamera.near = random.nextFloat() * 5;
    perspectiveCamera.far = (random.nextFloat() * 0.5f + 0.5f) * 5000;
    perspectiveCamera.up.rotateRad(new Vector3(randFloat(), randFloat(), randFloat()).nor(), randFloat());
    perspectiveCamera.update();
    objects[2] = perspectiveCamera;

    Pixmap pixmap = new Pixmap(2, 3, Pixmap.Format.RGBA8888);
    for (int i = 0; i < pixmap.getWidth(); i++) {
        for (int j = 0; j < pixmap.getHeight(); j++) {
            pixmap.drawPixel(i, j, random.nextInt());
        }
    }
    pixmap.setBlending(Pixmap.Blending.None);
    pixmap.setFilter(Pixmap.Filter.NearestNeighbour);
    objects[3] = pixmap;

    Pixmap pixmap2 = new Pixmap(50, 50, Pixmap.Format.RGBA8888);
    for (int i = 0; i < pixmap2.getWidth(); i++) {
        for (int j = 0; j < pixmap2.getHeight(); j++) {
            pixmap2.drawPixel(i, j, random.nextInt());
        }
    }
    pixmap2.setBlending(Pixmap.Blending.SourceOver);
    pixmap2.setFilter(Pixmap.Filter.BiLinear);
    objects[4] = pixmap2;

    Object[] returned = simpleRoundTrip(objects);

    pixmap.dispose();
    pixmap2.dispose();
    ((Pixmap)returned[3]).dispose();
    ((Pixmap)returned[4]).dispose();
}
 
开发者ID:CypherCove,项目名称:gdx-cclibs,代码行数:55,代码来源:GraphicsTest.java


注:本文中的com.badlogic.gdx.graphics.Pixmap.drawPixel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。