我现在已经尝试了一千次来自己解决这个问题而没有任何成功.我已经记录并调试了应用程序,根据我收集的信息,这是一个用于动画的大型spritesheet.这是一个大小为3000x1614像素的.png.spritesheet中有10x6个精灵,对于动画来说是必不可少的.精灵之间没有任何差距,使其尽可能保持内存效率.
这是我的方法,我将我的位图加载,解码并调整大小为用户手机与手机的宽高比,我正在构建游戏:
public Pixmap newResizedPixmap(String fileName, PixmapFormat format, double Width, double Height) {
// TODO Auto-generated method stub
Config config = null;
if (format == PixmapFormat.RGB565)
config = Config.RGB_565;
else if (format == PixmapFormat.ARGB4444)
config = Config.ARGB_4444;
else
config = Config.ARGB_8888;
Options options = new Options();
options.inPreferredConfig = config;
options.inPurgeable=true;
options.inInputShareable=true;
options.inDither=false;
InputStream in = null;
Bitmap bitmap = null;
try {
//OPEN FILE INTO INPUTSTREAM
in = assets.open(fileName);
//DECODE INPUTSTREAM
bitmap = BitmapFactory.decodeStream(in, null, options);
if (bitmap == null) …Run Code Online (Sandbox Code Playgroud) 如果矩阵中的每个2x2子矩阵的总和具有偶数行和列,我需要获得一个列表.
例如,假设我们有一个4x4矩阵(1); 函数应该如下计算它(我只想指出给定矩阵可以是任何nxm矩阵,其中n和m是偶数):
(1): [ [1, 2, 3, 4],
[5, 6, 7, 8],
[9, 10,11,12],
[13,14,15,16] ]
sum2x2 of (1):
1. 1+2+5+6 = 14
2. 3+4+7+8 = 22
3. 9+10+13+14 = 46
.
.
result: [14, 22, 46, ...]
Run Code Online (Sandbox Code Playgroud)
我想使用Data.Matrix并submatrix创建此列表.并且该函数应具有以下模式:
sum2x2 :: Matrix Double -> [Double]
Run Code Online (Sandbox Code Playgroud)
我已经开始编写这个函数,但我不知道如何从这里开始:
sum2x2 :: Matrix Double -> [Double]
sum2x2 m = if even (ncols m) && even (nrows m)
then what?
else error "sum2x2 takes only even matrices"
Run Code Online (Sandbox Code Playgroud)
submatrix …