⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 util.java

📁 tiled地图编辑器是2d的,很不错的国外软件,使用起来很方便的
💻 JAVA
字号:
/* *  Mappy Plugin for Tiled, (c) 2004 * *  This program is free software; you can redistribute it and/or modify *  it under the terms of the GNU General Public License as published by *  the Free Software Foundation; either version 2 of the License, or *  (at your option) any later version. * *  Adam Turk <aturk@biggeruniverse.com> *  Bjorn Lindeijer <b.lindeijer@xs4all.nl> */package tiled.plugins.mappy;import java.awt.*;import java.awt.image.DirectColorModel;import java.awt.image.MemoryImageSource;import java.io.IOException;import java.io.InputStream;import java.io.OutputStream;/** * @version $Id: Util.java 683 2006-06-25 14:17:37Z bjorn $ */public class Util{    private static final int LAST_BYTE = 0x000000FF;    public static long readLongReverse(InputStream in) throws IOException {        int a = in.read();        int b = in.read();        int c = in.read();        int d = in.read();        return (long) (a << 24 | b << 16 | c << 8 | d);    }    public static void writeLongReverse(long val, OutputStream out) throws IOException {        out.write((int) (val >> 24 & LAST_BYTE));        out.write((int) (val >> 16 & LAST_BYTE));        out.write((int) (val >> 8 & LAST_BYTE));        out.write((int) (val & LAST_BYTE));    }    public static int readShortReverse(InputStream in) throws IOException {        int a = in.read();        int b = in.read();        return a << 8 | b;    }    public static int readShort(InputStream in) throws IOException {        int a = in.read();        int b = in.read();        return a | b << 8;    }    public static void writeShort(int val, OutputStream out) throws IOException {        //TODO: this    }    public static Image readRawImage(InputStream in, int twidth, int theight) throws IOException {        DirectColorModel cm = new DirectColorModel(16, 0xF800, 0x07E0, 0x001F);        int [] pixels = new int[twidth * theight + 1];        int i, j;        for (i = 0; i < theight; i++)            for (j = 0; j < twidth; j++) {                pixels[i * twidth + j] = readShortReverse(in);                //System.out.println(pixels[i*width+j]);            }        MemoryImageSource s = new MemoryImageSource(twidth, theight, cm, pixels, 0, twidth);        return Toolkit.getDefaultToolkit().createImage(s);        //return(Toolkit.getDefaultToolkit().createImage(new FilteredImageSource(orig.getSource(),new TransImageFilter(cm.getRGB(64305)))));    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -