Show
Ignore:
Timestamp:
05/17/08 11:34:28 (8 months ago)
Author:
Frank Benoit <benoit@tionex.de>
branch:
default
Message:

Update to SWT 3.4M7

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • dwt/internal/image/GIFFileFormat.d

    r212 r213  
    2323import dwt.graphics.ImageLoader; 
    2424import tango.core.Exception; 
    25 import dwt.dwthelper.System; 
    2625import dwt.dwthelper.utils; 
     26 
    2727 
    2828final class GIFFileFormat : FileFormat { 
     
    6363            stream.read(signature); 
    6464            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'; 
    6666        } catch (Exception e) { 
    6767            return false; 
     
    7474     */ 
    7575    override ImageData[] loadFromByteStream() { 
    76         byte[3] signatureBytes
     76        byte[3] signature
    7777        byte[3] versionBytes; 
    7878        byte[7] block; 
    7979        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')) 
    8382                DWT.error(DWT.ERROR_INVALID_IMAGE); 
    8483 
     
    314313            inputStream.read(); 
    315314            // 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); 
    319317            // 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); 
    323320            // Read application data. 
    324321            byte[] data = new byte[0]; 
     
    334331            } 
    335332            // 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$ 
    337347                repeatCount = (data[1] & 0xFF) | ((data[2] & 0xFF) << 8); 
    338348                loader.repeatCount = repeatCount;