如何将位图分成也是位图的部分 [英] How to divide a bitmap into parts that are bitmaps too

查看:30
本文介绍了如何将位图分成也是位图的部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一些关于将位图分割成小块的可能方法的信息.

I need some info on the possible methods for dividing a bitmap in smaller pieces.

更重要的是,我需要一些选项来判断.我查了很多帖子,但我仍然不完全相信该怎么做:

More importantly I would need some options to judge. I have checked many posts and I am still not entirely convinced about what to do:

  1. 剪切位图部分
  2. 如何剪掉中间部分位图的区域?

这两个帖子是我找到的一些不错的选择,但我无法计算每种方法的 CPU 和 RAM 成本,或者我可能根本不应该为此计算而烦恼.尽管如此,如果我要做某事,为什么不从一开始就以最好的方式去做呢.

These two posts are some good options I found, but I cant calculate the CPU and RAM cost of each method, or maybe I should not bother with this calculation at all. Nonetheless if I am about to do something, why not do it the best way from the start.

如果能得到一些关于位图压缩的提示和链接,我将不胜感激,这样我可能会结合这两种方法获得更好的性能.

I would be grateful to get some tips and links on bitmap compression so maybe I get better performance combining the two methods.

推荐答案

您想将位图分成几部分.我假设您想从位图中剪切相等的部分.例如,假设您需要位图的四个相等部分.

You want to divide a bitmap into parts. I assume you want to cut equal parts from bitmap. Say for example you need four equal parts from a bitmap.

这是一种将位图划分为四个相等部分并将其放入位图数组的方法.

This is a method which divides a bitmap onto four equal parts and has it in an array of bitmaps.

public Bitmap[] splitBitmap(Bitmap src) {
    Bitmap[] divided = new Bitmap[4];
    imgs[0] = Bitmap.createBitmap(
        src,
        0, 0,
        src.getWidth() / 2, src.getHeight() / 2
    );
    imgs[1] = Bitmap.createBitmap(
        src,
        src.getWidth() / 2, 0,
        src.getWidth() / 2, src.getHeight() / 2
    );
    imgs[2] = Bitmap.createBitmap(
        src,
        0, src.getHeight() / 2,
        src.getWidth() / 2, src.getHeight() / 2
    );
    imgs[3] = Bitmap.createBitmap(
        src,
        src.getWidth() / 2, src.getHeight() / 2,
        src.getWidth() / 2, src.getHeight() / 2
    );
    return divided;
}

这篇关于如何将位图分成也是位图的部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆