【发布时间】:2014-03-11 18:54:11
【问题描述】:
我有位图字体的 XML 和原始位图数据。我想获取原始数据并在 BitMapData 中设置像素,以便制作我的字体。
在 flash 库中使用 haxe。
每当我运行我的代码时,我都会不断收到此错误:错误:错误 #2030:遇到文件结尾。在 flash.display::BitmapData/setPixels()
我正在尝试在 haxe 中使用这种技术,但失败了:https://github.com/PrimaryFeather/Starling-Framework/blob/master/starling/src/starling/text/MiniBitmapFont.as
我真的不知道问题是什么。 我没有包括下面的所有位图数据,因为它太大但有 310 个条目。
import flash.display.BitmapData;
import flash.geom.Rectangle;
import flash.utils.ByteArray;
...
private var BITMAP_WIDTH : Int = 128;
private var BITMAP_HEIGHT : Int = 64;
private var BITMAP_DATA : Array<Float> = [
2027613533, 3413039936, 202148514, 2266925598, 4206886452, 4286853117, 2034947,
3202703399, 352977282, 2957757964, 3113652880, 2158068882, 1468709156, 2268063717,
2779310143, 2101025806, 3416509055, 4215794539, 3602168838, 1038056207, 1932393374 ];
...
public function get_texture() : BitmapFont {
var bmpData : BitmapData = new BitmapData( BITMAP_WIDTH, BITMAP_HEIGHT );
var bmpBytes : ByteArray = new ByteArray();
var numBytes : Int = BITMAP_DATA.length;
bmpBytes.position = 0;
for ( i in 0...numBytes ) {
bmpBytes.writeUnsignedInt( Std.int( BITMAP_DATA[i] ) );
}
bmpBytes.position = 0;
//bmpBytes.uncompress();
bmpData.setPixels( new Rectangle( 0, 0, BITMAP_WIDTH, BITMAP_HEIGHT ), bmpBytes );
return new BitmapFont().loadAngelCode( bmpData, XML_DATA );
}
【问题讨论】:
标签: flash bitmap bytearray eof haxe