異なるプラットフォームでファイルIOの違いを経験した人はいますか? 100MB以上のTIFFファイルをストリームするLWJGLプログラムを作成しました。ストリーミングは、いくつかのMacとLinuxコンピュータでかなり速く起こるが、私の64ビットWindows 7 Desktopでは、マップの各タイルがロードされるまで数秒かかるようだ。JavaはWindows上でファイルを非常にゆっくり読み込みます
基本的に、私はTileクラスのインスタンスの2D配列を作成します。各タイルはTIFFファイルの512x512 MBの領域であり、レンダリングメソッドはメモリ内のタイルの領域がロードされているかどうかをチェックし、そうでない場合、ロードはThreadPoolExecutorでキューに入れられ、何も起こらなければ何も起こりません。描かれた。 TIFFへのアクセスは、RandomAccessFileインスタンスでファイルを読み取るTIFFクラスによって処理されます。これは、私はそれはあなたがファイルを読んでいる方法で行うことであることを疑う私はTIFF
public BufferedImage getRasterTile(Rectangle area) {
BufferedImage image = new BufferedImage(area.width, area.height,
BufferedImage.TYPE_INT_RGB);
try {
long[] bytesPerSample = new long[bitsPerSample.length];
for (int i = 0; i < bytesPerSample.length; i++) {
bytesPerSample[i] += bitsPerSample[i]/8 + bitsPerSample[i]
% 8 == 0 ? 0 : 1;
}
long bytesPerPixel = 0;
for (long bits : bitsPerSample) {
bytesPerPixel += bits/8 + bits % 8 == 0 ? 0 : 1;
}
long bytesPerRow = bytesPerPixel * imageWidth;
int strip, color;
byte red, green, blue;
for (int i = area.x; i < area.x + area.width; i++) {
for (int u = area.y; u < area.y + area.height; u++) {
if (i > 0 && u > 0 && i < imageWidth && u < imageLength) {
switch (planarConfiguration) {
case Chunky:
strip = (int) (u/rowsPerStrip);
seek(stripOffsets[strip]
+ (u - strip * rowsPerStrip)
* bytesPerRow + i * bytesPerPixel);
red = readByte();
green = readByte();
blue = readByte();
color = (red & 0x0ff) << 16 | (green & 0x0ff) << 8
| (blue & 0x0ff);
image.setRGB(i - area.x, u - area.y, color);
break;
case Planar:
strip = (u/(int) rowsPerStrip);
seek(stripOffsets[strip] + i);
red = readByte();
seek(stripOffsets[strip + (int) imageLength] + i);
green = readByte();
seek(stripOffsets[strip + 2 * (int) imageLength]
+ i);
blue = readByte();
color = (red & 0x0ff) << 16 | (green & 0x0ff) << 8
| (blue & 0x0ff);
image.setRGB(i - area.x, u - area.y, color);
break;
}
} else {
image.setRGB(i - area.x, u - area.y, 0);
}
}
}
} catch (IOException e) {
e.printStackTrace();
return null;
}
return image;
}
私は混乱しています。読みが遅いと言っているのですか?その場合、データを読み込んでいる様子を表示できますか?変換が遅いですか? –