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


Java ByteOrder.nativeOrder方法代码示例

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


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

示例1: setRGBA

import java.nio.ByteOrder; //导入方法依赖的package包/类
/**
 * Set a pixel in the image buffer
 * 
 * @param x The x position of the pixel to set
 * @param y The y position of the pixel to set
 * @param r The red component to set (0->255)
 * @param g The green component to set (0->255)
 * @param b The blue component to set (0->255)
 * @param a The alpha component to set (0->255)
 */
public void setRGBA(int x, int y, int r, int g, int b, int a) {
	if ((x < 0) || (x >= width) || (y < 0) || (y >= height)) {
		throw new RuntimeException("Specified location: "+x+","+y+" outside of image");
	}
	
	int ofs = ((x + (y * texWidth)) * 4);
	
	if (ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN) {
		rawData[ofs] = (byte) b;
		rawData[ofs + 1] = (byte) g;
		rawData[ofs + 2] = (byte) r;
		rawData[ofs + 3] = (byte) a;
	} else {
		rawData[ofs] = (byte) r;
		rawData[ofs + 1] = (byte) g;
		rawData[ofs + 2] = (byte) b;
		rawData[ofs + 3] = (byte) a;
	}
}
 
开发者ID:j-dong,项目名称:trashjam2017,代码行数:30,代码来源:ImageBuffer.java

示例2: setRGBA

import java.nio.ByteOrder; //导入方法依赖的package包/类
public void setRGBA(int x, int y, int r, int g, int b, int a){
    int offset = ((x+(y*this.width))*4);

    if(ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN){
        this.rawData[offset] = (byte)b;
        this.rawData[offset+1] = (byte)g;
        this.rawData[offset+2] = (byte)r;
        this.rawData[offset+3] = (byte)a;
    }
    else{
        this.rawData[offset] = (byte)r;
        this.rawData[offset+1] = (byte)g;
        this.rawData[offset+2] = (byte)b;
        this.rawData[offset+3] = (byte)a;
    }
}
 
开发者ID:RockBottomGame,项目名称:API,代码行数:17,代码来源:ImageBuffer.java

示例3: addServerStatsToSnooper

import java.nio.ByteOrder; //导入方法依赖的package包/类
public void addServerStatsToSnooper(Snooper playerSnooper)
{
    playerSnooper.addClientStat("fps", Integer.valueOf(debugFPS));
    playerSnooper.addClientStat("vsync_enabled", Boolean.valueOf(this.gameSettings.enableVsync));
    playerSnooper.addClientStat("display_frequency", Integer.valueOf(Display.getDisplayMode().getFrequency()));
    playerSnooper.addClientStat("display_type", this.fullscreen ? "fullscreen" : "windowed");
    playerSnooper.addClientStat("run_time", Long.valueOf((MinecraftServer.getCurrentTimeMillis() - playerSnooper.getMinecraftStartTimeMillis()) / 60L * 1000L));
    playerSnooper.addClientStat("current_action", this.getCurrentAction());
    playerSnooper.addClientStat("language", this.gameSettings.language == null ? "en_US" : this.gameSettings.language);
    String s = ByteOrder.nativeOrder() == ByteOrder.LITTLE_ENDIAN ? "little" : "big";
    playerSnooper.addClientStat("endianness", s);
    playerSnooper.addClientStat("subtitles", Boolean.valueOf(this.gameSettings.showSubtitles));
    playerSnooper.addClientStat("resource_packs", Integer.valueOf(this.mcResourcePackRepository.getRepositoryEntries().size()));
    int i = 0;

    for (ResourcePackRepository.Entry resourcepackrepository$entry : this.mcResourcePackRepository.getRepositoryEntries())
    {
        playerSnooper.addClientStat("resource_pack[" + i++ + "]", resourcepackrepository$entry.getResourcePackName());
    }

    if (this.theIntegratedServer != null && this.theIntegratedServer.getPlayerUsageSnooper() != null)
    {
        playerSnooper.addClientStat("snooper_partner", this.theIntegratedServer.getPlayerUsageSnooper().getUniqueID());
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:26,代码来源:Minecraft.java

示例4: encodeTest

import java.nio.ByteOrder; //导入方法依赖的package包/类
@Test
public void encodeTest() {

	final UnsafeEncoder unsafeEncoder = new UnsafeEncoder();

	final String testStr = "[email protected]$%THafw09\uD83D\uDD8F";

	byte[] values;
	if ( ByteOrder.nativeOrder() == ByteOrder.LITTLE_ENDIAN ) {
		values = testStr.getBytes( StandardCharsets.UTF_16LE );
	} else {
		values = testStr.getBytes( StandardCharsets.UTF_16BE );
	}

	int i = 0;
	for ( byte oneByte : unsafeEncoder.encode( testStr ) ) {
		Assert.assertEquals( values[i++], oneByte );
	}
}
 
开发者ID:cinnom,项目名称:nano-cuckoo,代码行数:20,代码来源:UnsafeEncoderTest.java

示例5: init

import java.nio.ByteOrder; //导入方法依赖的package包/类
public void init(GameContainer container) throws SlickException {
   // detect what endian we have
   if (ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN) {
          endian = "Big endian";
       } else if (ByteOrder.nativeOrder() == ByteOrder.LITTLE_ENDIAN) {
          endian = "Little endian";
       } else
          endian = "no idea";
   
   redImageBuffer = new ImageBuffer(100,100);
   fillImageBufferWithColor(redImageBuffer, Color.red, 100, 100);
   
   blueImageBuffer = new ImageBuffer(100,100);
   fillImageBufferWithColor(blueImageBuffer, Color.blue, 100, 100);
   
   fromRed = redImageBuffer.getImage();
   fromBlue = blueImageBuffer.getImage();
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:19,代码来源:ImageBufferEndianTest.java

示例6: basicGetInt

import java.nio.ByteOrder; //导入方法依赖的package包/类
private int basicGetInt(final int pos) {
  long addr = this.chunk.getAddressForReadingData(pos, 4);
  if (unaligned) {
    int result = AddressableMemoryManager.readInt(addr);
    if (ByteOrder.nativeOrder() == ByteOrder.LITTLE_ENDIAN) {
      result = Integer.reverseBytes(result);
    }
    return result;
  } else {
    byte b0 = AddressableMemoryManager.readByte(addr++);
    byte b1 = AddressableMemoryManager.readByte(addr++);
    byte b2 = AddressableMemoryManager.readByte(addr++);
    byte b3 = AddressableMemoryManager.readByte(addr);
    return (b0 << 24) + ((b1 & 255) << 16) + ((b2 & 255) << 8) + ((b3 & 255) << 0);
  }
}
 
开发者ID:ampool,项目名称:monarch,代码行数:17,代码来源:ByteBufferInputStream.java

示例7: addServerStatsToSnooper

import java.nio.ByteOrder; //导入方法依赖的package包/类
public void addServerStatsToSnooper(PlayerUsageSnooper playerSnooper)
{
    playerSnooper.addClientStat("fps", Integer.valueOf(debugFPS));
    playerSnooper.addClientStat("vsync_enabled", Boolean.valueOf(this.gameSettings.enableVsync));
    playerSnooper.addClientStat("display_frequency", Integer.valueOf(Display.getDisplayMode().getFrequency()));
    playerSnooper.addClientStat("display_type", this.fullscreen ? "fullscreen" : "windowed");
    playerSnooper.addClientStat("run_time", Long.valueOf((MinecraftServer.getCurrentTimeMillis() - playerSnooper.getMinecraftStartTimeMillis()) / 60L * 1000L));
    playerSnooper.addClientStat("current_action", this.func_181538_aA());
    String s = ByteOrder.nativeOrder() == ByteOrder.LITTLE_ENDIAN ? "little" : "big";
    playerSnooper.addClientStat("endianness", s);
    playerSnooper.addClientStat("resource_packs", Integer.valueOf(this.mcResourcePackRepository.getRepositoryEntries().size()));
    int i = 0;

    for (ResourcePackRepository.Entry resourcepackrepository$entry : this.mcResourcePackRepository.getRepositoryEntries())
    {
        playerSnooper.addClientStat("resource_pack[" + i++ + "]", resourcepackrepository$entry.getResourcePackName());
    }

    if (this.theIntegratedServer != null && this.theIntegratedServer.getPlayerUsageSnooper() != null)
    {
        playerSnooper.addClientStat("snooper_partner", this.theIntegratedServer.getPlayerUsageSnooper().getUniqueID());
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:24,代码来源:Minecraft.java

示例8: basicGetLong

import java.nio.ByteOrder; //导入方法依赖的package包/类
private long basicGetLong(final int pos) {
  long addr = this.chunk.getAddressForReadingData(pos, 8);
  if (unaligned) {
    long result = AddressableMemoryManager.readLong(addr);
    if (ByteOrder.nativeOrder() == ByteOrder.LITTLE_ENDIAN) {
      result = Long.reverseBytes(result);
    }
    return result;
  } else {
    byte b0 = AddressableMemoryManager.readByte(addr++);
    byte b1 = AddressableMemoryManager.readByte(addr++);
    byte b2 = AddressableMemoryManager.readByte(addr++);
    byte b3 = AddressableMemoryManager.readByte(addr++);
    byte b4 = AddressableMemoryManager.readByte(addr++);
    byte b5 = AddressableMemoryManager.readByte(addr++);
    byte b6 = AddressableMemoryManager.readByte(addr++);
    byte b7 = AddressableMemoryManager.readByte(addr);
    return (((long) b0 << 56) + ((long) (b1 & 255) << 48) + ((long) (b2 & 255) << 40)
        + ((long) (b3 & 255) << 32) + ((long) (b4 & 255) << 24) + ((b5 & 255) << 16)
        + ((b6 & 255) << 8) + ((b7 & 255) << 0));
  }
}
 
开发者ID:ampool,项目名称:monarch,代码行数:23,代码来源:ByteBufferInputStream.java

示例9: test

import java.nio.ByteOrder; //导入方法依赖的package包/类
public void test() throws Exception {
    CustomPlugin plugin = new CustomPlugin();
    PluginRepository.registerPlugin(plugin);
    List<Plugin> plugins = new ArrayList<>();
    plugins.add(createPlugin(CustomPlugin.NAME));
    ImagePluginStack stack = ImagePluginConfiguration.parseConfiguration(new Jlink.PluginsConfiguration(plugins,
            null, null));
    ResourcePoolManager inResources = new ResourcePoolManager(ByteOrder.nativeOrder(), new CustomStringTable());
    inResources.add(ResourcePoolEntry.create("/aaa/bbb/res1.class", new byte[90]));
    inResources.add(ResourcePoolEntry.create("/aaa/bbb/res2.class", new byte[90]));
    inResources.add(ResourcePoolEntry.create("/aaa/bbb/res3.class", new byte[90]));
    inResources.add(ResourcePoolEntry.create("/aaa/ddd/res1.class", new byte[90]));
    inResources.add(ResourcePoolEntry.create("/aaa/res1.class", new byte[90]));
    ResourcePool outResources = stack.visitResources(inResources);
    Collection<String> input = inResources.entries()
            .map(Object::toString)
            .collect(Collectors.toList());
    Collection<String> output = outResources.entries()
            .map(Object::toString)
            .collect(Collectors.toList());
    if (!input.equals(output)) {
        throw new AssertionError("Input and output resources differ: input: "
                + input + ", output: " + output);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:26,代码来源:PrevisitorTest.java

示例10: putColorMultiplier

import java.nio.ByteOrder; //导入方法依赖的package包/类
/**
 * Modify the color data of the given vertex with the given multipliers.
 *  
 * @param vertexIndex The index of the vertex to modify, where 0 is the last one added, 1 is the second last, etc.
 */
public void putColorMultiplier(float red, float green, float blue, int vertexIndex)
{
    int i = this.getColorIndex(vertexIndex);
    int j = -1;

    if (!this.noColor)
    {
        j = this.rawIntBuffer.get(i);

        if (ByteOrder.nativeOrder() == ByteOrder.LITTLE_ENDIAN)
        {
            int k = (int)((float)(j & 255) * red);
            int l = (int)((float)(j >> 8 & 255) * green);
            int i1 = (int)((float)(j >> 16 & 255) * blue);
            j = j & -16777216;
            j = j | i1 << 16 | l << 8 | k;
        }
        else
        {
            int j1 = (int)((float)(j >> 24 & 255) * red);
            int k1 = (int)((float)(j >> 16 & 255) * green);
            int l1 = (int)((float)(j >> 8 & 255) * blue);
            j = j & 255;
            j = j | j1 << 24 | k1 << 16 | l1 << 8;
        }
    }

    this.rawIntBuffer.put(i, j);
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:35,代码来源:VertexBuffer.java

示例11: putColorRGBA

import java.nio.ByteOrder; //导入方法依赖的package包/类
/**
 * Write the given color data of 4 bytes at the given index into the vertex data buffer, accounting for system
 * endianness.
 *  
 * @param index The index in the vertex data buffer to which the color data will be written, in {@code int}s
 */
public void putColorRGBA(int index, int red, int green, int blue, int alpha)
{
    if (ByteOrder.nativeOrder() == ByteOrder.LITTLE_ENDIAN)
    {
        this.rawIntBuffer.put(index, alpha << 24 | blue << 16 | green << 8 | red);
    }
    else
    {
        this.rawIntBuffer.put(index, red << 24 | green << 16 | blue << 8 | alpha);
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:18,代码来源:VertexBuffer.java

示例12: getByteOrderByte

import java.nio.ByteOrder; //导入方法依赖的package包/类
static byte getByteOrderByte() {
    // 'l' - for little endian, 'B' - for big endian.
    return ByteOrder.nativeOrder() == ByteOrder.LITTLE_ENDIAN ?
        (byte)0x6C : (byte)0x42;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:6,代码来源:MotifDnDConstants.java

示例13: color

import java.nio.ByteOrder; //导入方法依赖的package包/类
public VertexBuffer color(int red, int green, int blue, int alpha)
{
    if (this.noColor)
    {
        return this;
    }
    else
    {
        int i = this.vertexCount * this.vertexFormat.getNextOffset() + this.vertexFormat.getOffset(this.vertexFormatIndex);

        switch (this.vertexFormatElement.getType())
        {
            case FLOAT:
                this.byteBuffer.putFloat(i, (float)red / 255.0F);
                this.byteBuffer.putFloat(i + 4, (float)green / 255.0F);
                this.byteBuffer.putFloat(i + 8, (float)blue / 255.0F);
                this.byteBuffer.putFloat(i + 12, (float)alpha / 255.0F);
                break;

            case UINT:
            case INT:
                this.byteBuffer.putFloat(i, (float)red);
                this.byteBuffer.putFloat(i + 4, (float)green);
                this.byteBuffer.putFloat(i + 8, (float)blue);
                this.byteBuffer.putFloat(i + 12, (float)alpha);
                break;

            case USHORT:
            case SHORT:
                this.byteBuffer.putShort(i, (short)red);
                this.byteBuffer.putShort(i + 2, (short)green);
                this.byteBuffer.putShort(i + 4, (short)blue);
                this.byteBuffer.putShort(i + 6, (short)alpha);
                break;

            case UBYTE:
            case BYTE:
                if (ByteOrder.nativeOrder() == ByteOrder.LITTLE_ENDIAN)
                {
                    this.byteBuffer.put(i, (byte)red);
                    this.byteBuffer.put(i + 1, (byte)green);
                    this.byteBuffer.put(i + 2, (byte)blue);
                    this.byteBuffer.put(i + 3, (byte)alpha);
                }
                else
                {
                    this.byteBuffer.put(i, (byte)alpha);
                    this.byteBuffer.put(i + 1, (byte)blue);
                    this.byteBuffer.put(i + 2, (byte)green);
                    this.byteBuffer.put(i + 3, (byte)red);
                }
        }

        this.nextVertexFormatIndex();
        return this;
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:58,代码来源:VertexBuffer.java

示例14: open

import java.nio.ByteOrder; //导入方法依赖的package包/类
public static BasicImageReader open(Path imagePath) throws IOException {
    return new BasicImageReader(imagePath, ByteOrder.nativeOrder());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:4,代码来源:BasicImageReader.java

示例15: ImageStream

import java.nio.ByteOrder; //导入方法依赖的package包/类
public ImageStream() {
    this(1024, ByteOrder.nativeOrder());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:4,代码来源:ImageStream.java


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