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


Java Base64Coder.encode方法代码示例

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


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

示例1: save

import com.badlogic.gdx.utils.Base64Coder; //导入方法依赖的package包/类
public static void save(TilePrefab prefab, String outputFilename) {
	if (prefab == null)
		throw new IllegalArgumentException();

	JsonTilePrefab jsonPrefab = new JsonTilePrefab();
	jsonPrefab.width = prefab.getWidth();
	jsonPrefab.height = prefab.getHeight();
	jsonPrefab.depth = prefab.getDepth();

	byte[] dataBytes = new byte[prefab.getData().length * TileDataSerializer.TILE_SIZE_BYTES];
	ByteBuffer buffer = ByteBuffer.wrap(dataBytes);

	TileDataSerializer.serialize(prefab, buffer);
	jsonPrefab.data = new String(Base64Coder.encode(dataBytes));

	Json json = new Json();
	String output = json.prettyPrint(jsonPrefab);
	FileHandle outputFile = Gdx.files.local(outputFilename);
	outputFile.writeString(output, false);
}
 
开发者ID:gered,项目名称:gdx-tilemap3d,代码行数:21,代码来源:TilePrefabSaver.java

示例2: send

import com.badlogic.gdx.utils.Base64Coder; //导入方法依赖的package包/类
@Override
public void send(Object object, SendMode mode) {
    if(!(object instanceof Packet)) throw new RuntimeException("All sent objects must be packets!");
    Packet p = (Packet)object;
    buffer.position(0);
    buffer.put(Registrator.getID(object.getClass()));
    p.write(buffer);
    int pos = buffer.position();
    buffer.position(0);
    byte[] out = new byte[pos];
    buffer.get(out);
    String string = new String(Base64Coder.encode(out));
    if(debug) UCore.log("Sending string: " + string);
    socket.send(string);
}
 
开发者ID:Anuken,项目名称:Mindustry,代码行数:16,代码来源:JavaWebsocketClient.java

示例3: send

import com.badlogic.gdx.utils.Base64Coder; //导入方法依赖的package包/类
@Override
public void send(Object object, SendMode mode){
    if(socket != null){
        try {
            synchronized (buffer) {
                buffer.position(0);
                if(debug) UCore.log("Sending object with ID " + Registrator.getID(object.getClass()));
                serializer.write(buffer, object);
                int pos = buffer.position();
                buffer.position(0);
                byte[] out = new byte[pos];
                buffer.get(out);
                String string = new String(Base64Coder.encode(out));
                if(debug) UCore.log("Sending string: " + string);
                socket.send(string);
            }
        }catch (Exception e){
            e.printStackTrace();
            connections.remove(this);
        }
    }else if (connection != null) {
        if (mode == SendMode.tcp) {
            connection.sendTCP(object);
        } else {
            connection.sendUDP(object);
        }
    }
}
 
开发者ID:Anuken,项目名称:Mindustry,代码行数:29,代码来源:KryoServer.java

示例4: send

import com.badlogic.gdx.utils.Base64Coder; //导入方法依赖的package包/类
@Override
public void send(Object object, SendMode mode) {
    if(!(object instanceof Packet)) throw new RuntimeException("All sent objects must be packets!");
    Packet p = (Packet)object;
    buffer.position(0);
    buffer.put(Registrator.getID(object.getClass()));
    p.write(buffer);
    int pos = buffer.position();
    buffer.position(0);
    byte[] out = new byte[pos];
    buffer.get(out);
    String string = new String(Base64Coder.encode(out));
    socket.send(string);
}
 
开发者ID:Anuken,项目名称:Mindustry,代码行数:15,代码来源:WebsocketClient.java

示例5: createTextureFromBytes

import com.badlogic.gdx.utils.Base64Coder; //导入方法依赖的package包/类
/**
 * Creates texture region from byte[].
 * <p>
 * GWT platform requires additional step (as far as i know) to deal with Pixmap. It is need to load Image element
 * and wait until it is loaded.
 *
 * @param bytes    Image byte[] representation, not null
 * @param consumer Consumer where you should deal with region, not null
 */
public static void createTextureFromBytes(byte[] bytes, final Consumer<TextureRegion> consumer)
{
    String base64 = "data:image/png;base64," + new String(Base64Coder.encode(bytes));
    final Image image = new Image();
    image.setVisible(false);
    image.addLoadHandler(new LoadHandler()
    {
        @Override
        public void onLoad(LoadEvent event)
        {
            ImageElement imageElement = image.getElement().cast();
            Pixmap pixmap = new Pixmap(imageElement);
            Gdx.app.log("ImageHelper", "pixmap: " + pixmap.getWidth() + "/" + pixmap.getHeight());
            final int orgWidth = pixmap.getWidth();
            final int orgHeight = pixmap.getHeight();
            int width = MathUtils.nextPowerOfTwo(orgWidth);
            int height = MathUtils.nextPowerOfTwo(orgHeight);
            final Pixmap potPixmap = new Pixmap(width, height, pixmap.getFormat());
            potPixmap.drawPixmap(pixmap, 0, 0, 0, 0, pixmap.getWidth(), pixmap.getHeight());
            pixmap.dispose();
            TextureRegion region = new TextureRegion(new Texture(potPixmap), 0, 0, orgWidth, orgHeight);
            potPixmap.dispose();
            RootPanel.get().remove(image);
            consumer.accept(region);
        }
    });
    image.setUrl(base64);
    RootPanel.get().add(image);
}
 
开发者ID:mk-5,项目名称:gdx-fireapp,代码行数:39,代码来源:ImageHelper.java

示例6: encrypt

import com.badlogic.gdx.utils.Base64Coder; //导入方法依赖的package包/类
public static String encrypt(String input, String key){
    byte[] crypted = null;
    try{
        SecretKeySpec skey = new SecretKeySpec(key.getBytes(), "AES");
        Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
        cipher.init(Cipher.ENCRYPT_MODE, skey);
        crypted = cipher.doFinal(input.getBytes());
    }catch(Exception e){
        System.out.println(e.toString());
    }
    return new String(Base64Coder.encode(crypted));
}
 
开发者ID:Xemplar,项目名称:NerdShooter,代码行数:13,代码来源:NetworkHandle.java

示例7: encode

import com.badlogic.gdx.utils.Base64Coder; //导入方法依赖的package包/类
public static String encode(byte[] signature) {
	return new String(Base64Coder.encode(signature));
}
 
开发者ID:TomGrill,项目名称:gdx-twitter,代码行数:4,代码来源:Base64BytesToStringEncoder.java

示例8: encode

import com.badlogic.gdx.utils.Base64Coder; //导入方法依赖的package包/类
public byte[] encode(byte[] src) {
	char[] base64 = Base64Coder.encode(src); 
	String str = new String(base64);
	return str.getBytes();
}
 
开发者ID:Peergos,项目名称:Peergos,代码行数:6,代码来源:Base64.java

示例9: encodeToString

import com.badlogic.gdx.utils.Base64Coder; //导入方法依赖的package包/类
public String encodeToString(byte[] src) {
	char[] base64 = Base64Coder.encode(src); 
	return new String(base64);
}
 
开发者ID:Peergos,项目名称:Peergos,代码行数:5,代码来源:Base64.java


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