Changeset 213:36f5cb12e1a2 for dwt/internal/image/GIFFileFormat.d
- Timestamp:
- 05/17/08 11:34:28 (8 months ago)
- Files:
-
- dwt/internal/image/GIFFileFormat.d (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
dwt/internal/image/GIFFileFormat.d
r212 r213 23 23 import dwt.graphics.ImageLoader; 24 24 import tango.core.Exception; 25 import dwt.dwthelper.System;26 25 import dwt.dwthelper.utils; 26 27 27 28 28 final class GIFFileFormat : FileFormat { … … 63 63 stream.read(signature); 64 64 stream.unread(signature); 65 return cast(String)signature == "GIF"; //$NON-NLS-1$65 return signature[0] is 'G' && signature[1] is 'I' && signature[2] is 'F'; 66 66 } catch (Exception e) { 67 67 return false; … … 74 74 */ 75 75 override ImageData[] loadFromByteStream() { 76 byte[3] signature Bytes;76 byte[3] signature; 77 77 byte[3] versionBytes; 78 78 byte[7] block; 79 79 try { 80 inputStream.read(signatureBytes); 81 signature = cast(String)signatureBytes.dup; 82 if (signature != "GIF") //$NON-NLS-1$ 80 inputStream.read(signature); 81 if (!(signature[0] is 'G' && signature[1] is 'I' && signature[2] is 'F')) 83 82 DWT.error(DWT.ERROR_INVALID_IMAGE); 84 83 … … 314 313 inputStream.read(); 315 314 // Read application identifier. 316 byte[] applicationBytes = new byte[8]; 317 inputStream.read(applicationBytes); 318 String application = cast(String)(applicationBytes.dup); 315 byte[] application = new byte[8]; 316 inputStream.read(application); 319 317 // Read authentication code. 320 byte[] authenticationBytes = new byte[3]; 321 inputStream.read(authenticationBytes); 322 String authentication = cast(String)(authenticationBytes.dup); 318 byte[] authentication = new byte[3]; 319 inputStream.read(authentication); 323 320 // Read application data. 324 321 byte[] data = new byte[0]; … … 334 331 } 335 332 // Look for the NETSCAPE 'repeat count' field for an animated GIF. 336 if (application=="NETSCAPE" && authentication=="2.0" && data[0] is 01) { //$NON-NLS-1$ //$NON-NLS-2$ 333 bool netscape = 334 application[0] is 'N' && 335 application[1] is 'E' && 336 application[2] is 'T' && 337 application[3] is 'S' && 338 application[4] is 'C' && 339 application[5] is 'A' && 340 application[6] is 'P' && 341 application[7] is 'E'; 342 bool authentic = 343 authentication[0] is '2' && 344 authentication[1] is '.' && 345 authentication[2] is '0'; 346 if (netscape && authentic && data[0] is 01) { //$NON-NLS-1$ //$NON-NLS-2$ 337 347 repeatCount = (data[1] & 0xFF) | ((data[2] & 0xFF) << 8); 338 348 loader.repeatCount = repeatCount;
