【问题标题】:Create multiple image from Array从数组创建多个图像
【发布时间】:2015-06-18 13:45:04
【问题描述】:

我有一个点坐标数组。数据太大,不允许我创建一个 BufferedImage,所以我想要如下所示。

要创建第一个 BufferedImage,请先获取 100 行。然后循环再次开始,但是创建一个新的 BufferedImage,其行的范围从 101 到 200……这样做直到循环到达数组的末尾。

int temp = 100;

while (listPing.size() < temp) {
  // Do something
  // Create BufferedImage
  temp = temp * 2;
}

我该怎么做?

【问题讨论】:

标签: java arrays loops


【解决方案1】:

我不太确定我明白你的意思,但我认为你正在寻找的方式如下:

int total = listPing.size(); //calculate the total number lines in here
int temp = 100; //stepsize
int actualValue = 0;

while(actualValue < total) {
    Do something
    Create BufferedImage
    actualValue += temp;
}

另一种可能性是预先计算您要经过的次数,方法是除以总大小/步长,然后创建一个 for 循环。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-05-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-05-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多