comparison dwt/internal/image/GIFFileFormat.d @ 212:ab60f3309436

reverted the char[] to String and use the an alias.
author Frank Benoit <benoit@tionex.de>
date Mon, 05 May 2008 00:12:38 +0200
parents 41dbc4d9faab
children 36f5cb12e1a2
comparison
equal deleted inserted replaced
211:ff59aeb96cac 212:ab60f3309436
21 import dwt.graphics.ImageData; 21 import dwt.graphics.ImageData;
22 import dwt.graphics.ImageLoaderEvent; 22 import dwt.graphics.ImageLoaderEvent;
23 import dwt.graphics.ImageLoader; 23 import dwt.graphics.ImageLoader;
24 import tango.core.Exception; 24 import tango.core.Exception;
25 import dwt.dwthelper.System; 25 import dwt.dwthelper.System;
26 import dwt.dwthelper.utils;
26 27
27 final class GIFFileFormat : FileFormat { 28 final class GIFFileFormat : FileFormat {
28 char[] signature; 29 String signature;
29 int screenWidth, screenHeight, backgroundPixel, bitsPerPixel, defaultDepth; 30 int screenWidth, screenHeight, backgroundPixel, bitsPerPixel, defaultDepth;
30 int disposalMethod = 0; 31 int disposalMethod = 0;
31 int delayTime = 0; 32 int delayTime = 0;
32 int transparentPixel = -1; 33 int transparentPixel = -1;
33 int repeatCount = 1; 34 int repeatCount = 1;
59 override bool isFileFormat(LEDataInputStream stream) { 60 override bool isFileFormat(LEDataInputStream stream) {
60 try { 61 try {
61 byte[3] signature; 62 byte[3] signature;
62 stream.read(signature); 63 stream.read(signature);
63 stream.unread(signature); 64 stream.unread(signature);
64 return cast(char[])signature == "GIF"; //$NON-NLS-1$ 65 return cast(String)signature == "GIF"; //$NON-NLS-1$
65 } catch (Exception e) { 66 } catch (Exception e) {
66 return false; 67 return false;
67 } 68 }
68 } 69 }
69 70
75 byte[3] signatureBytes; 76 byte[3] signatureBytes;
76 byte[3] versionBytes; 77 byte[3] versionBytes;
77 byte[7] block; 78 byte[7] block;
78 try { 79 try {
79 inputStream.read(signatureBytes); 80 inputStream.read(signatureBytes);
80 signature = cast(char[])signatureBytes.dup; 81 signature = cast(String)signatureBytes.dup;
81 if (signature != "GIF") //$NON-NLS-1$ 82 if (signature != "GIF") //$NON-NLS-1$
82 DWT.error(DWT.ERROR_INVALID_IMAGE); 83 DWT.error(DWT.ERROR_INVALID_IMAGE);
83 84
84 inputStream.read(versionBytes); 85 inputStream.read(versionBytes);
85 86
312 // Read size of block = 0x0B. 313 // Read size of block = 0x0B.
313 inputStream.read(); 314 inputStream.read();
314 // Read application identifier. 315 // Read application identifier.
315 byte[] applicationBytes = new byte[8]; 316 byte[] applicationBytes = new byte[8];
316 inputStream.read(applicationBytes); 317 inputStream.read(applicationBytes);
317 char[] application = cast(char[])(applicationBytes.dup); 318 String application = cast(String)(applicationBytes.dup);
318 // Read authentication code. 319 // Read authentication code.
319 byte[] authenticationBytes = new byte[3]; 320 byte[] authenticationBytes = new byte[3];
320 inputStream.read(authenticationBytes); 321 inputStream.read(authenticationBytes);
321 char[] authentication = cast(char[])(authenticationBytes.dup); 322 String authentication = cast(String)(authenticationBytes.dup);
322 // Read application data. 323 // Read application data.
323 byte[] data = new byte[0]; 324 byte[] data = new byte[0];
324 byte[] block = new byte[255]; 325 byte[] block = new byte[255];
325 int size = inputStream.read(); 326 int size = inputStream.read();
326 while ((size > 0) && (inputStream.read(block, 0, size) !is -1)) { 327 while ((size > 0) && (inputStream.read(block, 0, size) !is -1)) {