當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。