Changeset 3021 for libpipi


Ignore:
Timestamp:
Oct 19, 2008, 1:28:27 PM (12 years ago)
Author:
Jean-Yves Lamoureux
Message:
  • CoreImage? codec now recognizes file extention and saves the image according to it
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libpipi/trunk/pipi/codec/coreimage.m

    r3020 r3021  
    9191    memcpy([bitmap bitmapData], p->pixels, p->w*p->h*4);
    9292
    93     [[bitmap representationUsingType:NSPNGFileType properties:nil] writeToFile:n  atomically:YES];
     93    NSBitmapImageFileType type = NSPNGFileType;
     94   
     95   
     96    if(strlen(name) > 4)
     97    {
     98        char *ext = (char*)&name[strlen(name) - 4];
     99        if(     !strncasecmp(ext, ".png",  3)) type = NSPNGFileType;
     100        else if(!strncasecmp(ext, "jpeg",  4)) type = NSJPEGFileType;
     101        else if(!strncasecmp(ext, ".jpg",  3)) type = NSJPEGFileType;
     102        else if(!strncasecmp(ext, ".bmp",  3)) type = NSBMPFileType;
     103        else if(!strncasecmp(ext, ".tif",  3)) type = NSTIFFFileType;
     104        else if(!strncasecmp(ext, ".tiff", 3)) type = NSTIFFFileType;
     105        else if(!strncasecmp(ext, ".gif",  3)) type = NSGIFFileType;
     106        else if(!strncasecmp(ext, ".bmp",  3)) type = NSBMPFileType;
     107        else if(!strncasecmp(ext, ".jp2",  3)) type = NSJPEG2000FileType;
     108        else if(!strncasecmp(ext, ".j2k",  3)) type = NSJPEG2000FileType;
     109    }
     110   
     111   
     112    [[bitmap representationUsingType:type properties:nil] writeToFile:n  atomically:YES];
    94113    [autoreleasepool release];
    95114
Note: See TracChangeset for help on using the changeset viewer.