小编Rob*_*oss的帖子

BitmapFactory.decodeStream在设置选项时返回null

我有问题BitmapFactory.decodeStream(inputStream).在没有选项的情况下使用它时,它将返回一个图像.但是当我将它与选项一起使用时,.decodeStream(inputStream, null, options)它永远不会返回Bitmaps.

我要做的是在实际加载之前对Bitmap进行下采样以节省内存.我读过一些很好的指南,但都没有使用.decodeStream.

工作很精细

URL url = new URL(sUrl);
HttpURLConnection connection  = (HttpURLConnection) url.openConnection();

InputStream is = connection.getInputStream();
Bitmap img = BitmapFactory.decodeStream(is, null, options);
Run Code Online (Sandbox Code Playgroud)

什么都不行

InputStream is = connection.getInputStream();
Bitmap img = BitmapFactory.decodeStream(is, null, options);

InputStream is = connection.getInputStream();

Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;

BitmapFactory.decodeStream(is, null, options);

Boolean scaleByHeight = Math.abs(options.outHeight - TARGET_HEIGHT) >= Math.abs(options.outWidth - TARGET_WIDTH);

if (options.outHeight * options.outWidth * 2 >= 200*100*2){
    // Load, …
Run Code Online (Sandbox Code Playgroud)

java android image bitmap

87
推荐指数
2
解决办法
6万
查看次数

在PHP中生成快速伪随机数据

我需要生成不可压缩的数据(因此伪随机),并尝试使用下面的代码.但它只产生大约10MB/s的数据.我需要大约100-200 MB/s.你有什么建议吗?

if ($length > 8*1024*1024){ //Default max string length in php.
    while (($length - $bytesGenerated)>8*1024*1024){
        $bytesGenerated = $bytesGenerated + (8*1024*1024);
        print(openssl_random_pseudo_bytes(8*1024*1024));
    }
}
print(openssl_random_pseudo_bytes($length - $bytesGenerated));
Run Code Online (Sandbox Code Playgroud)

php random

7
推荐指数
1
解决办法
669
查看次数

JScrollpane中的背景图像与JTable

我试图在JScrollPane中的JTable后面添加一个居中的背景图像.背景相对于视口的位置应居中且静态.

我曾尝试将JScrollPane添加到带有绘制图像的JPanel中,并使其他所有内容都是半透明的,但结果很难看并且有渲染问题.

java swing jtable jscrollpane

3
推荐指数
1
解决办法
3154
查看次数

标签 统计

java ×2

android ×1

bitmap ×1

image ×1

jscrollpane ×1

jtable ×1

php ×1

random ×1

swing ×1