Show
Ignore:
Timestamp:
03/21/12 18:36:20 (3 years ago)
Author:
robert
Message:

Ran script to remove trailing spaces and tabs

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/src/osgPlugins/imageio/ReaderWriterImageIO.cpp

    r12913 r13041  
    4242 ***** Begin Callback functions for istream block reading ***** 
    4343 **************************************************************/ 
    44   
     44 
    4545// This callback reads some bytes from an istream and copies it 
    4646// to a Quartz buffer (supplied by Apple framework). 
     
    141141        MyProviderReleaseInfoCallback 
    142142    }; 
    143      
     143 
    144144    CGDataProviderRef data_provider = CGDataProviderCreateSequential(&fin, &provider_callbacks); 
    145145 
     
    154154        MyProviderReleaseInfoCallback 
    155155    }; 
    156      
     156 
    157157    CGDataProviderRef data_provider = CGDataProviderCreate(&fin, &provider_callbacks); 
    158158#endif 
     
    170170 
    171171    image_ref = CGImageSourceCreateImageAtIndex(source_ref, 0, NULL); 
    172      
     172 
    173173    /* Don't need the SourceRef any more (error or not) */ 
    174174    CFRelease(source_ref); 
     
    198198        return NULL; 
    199199    } 
    200   
     200 
    201201    /* Create a CFURL from a CFString */ 
    202202    the_url = CFURLCreateWithFileSystemPath( 
    203         NULL,  
     203        NULL, 
    204204        cf_string, 
    205205        kCFURLPOSIXPathStyle, 
     
    209209    /* Don't need the CFString any more (error or not) */ 
    210210    CFRelease(cf_string); 
    211      
     211 
    212212    if(!the_url) 
    213213    { 
     
    216216    } 
    217217 
    218      
     218 
    219219    source_ref = CGImageSourceCreateWithURL(the_url, NULL); 
    220220    /* Don't need the URL any more (error or not) */ 
     
    233233        OSG_WARN << "CreateCGImageFromFile :: could not get Image" << std::endl; 
    234234    } 
    235      
     235 
    236236    /* Don't need the SourceRef any more (error or not) */ 
    237237    CFRelease(source_ref); 
     
    259259//    size_t bits_per_component = CGImageGetBitsPerComponent(image_ref); 
    260260    size_t bits_per_component = 8; 
    261      
     261 
    262262    CGImageAlphaInfo alpha_info = CGImageGetAlphaInfo(image_ref); 
    263      
     263 
    264264    GLint internal_format; 
    265265    GLenum pixel_format; 
    266266    GLenum data_type; 
    267      
     267 
    268268    void* image_data = calloc(the_width * 4, the_height); 
    269269 
     
    289289                pixel_format = GL_BGRA_EXT; 
    290290                data_type = GL_UNSIGNED_INT_8_8_8_8_REV; 
    291                  
     291 
    292292                bytes_per_row = the_width*4; 
    293293//                color_space = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB); 
     
    298298#else 
    299299                bitmap_info = kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Little; /* XRGB Little Endian */ 
    300 #endif  
     300#endif 
    301301            } 
    302302            else 
     
    325325#else 
    326326            bitmap_info = kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Little; /* XRGB Little Endian */ 
    327 #endif        
     327#endif 
    328328            break; 
    329329        } 
     
    331331        // Tatsuhiro Nishioka 
    332332        // 16 bpp grayscale (8 bit white and 8 bit alpha) causes invalid argument combination 
    333         // in CGBitmapContextCreate.  
     333        // in CGBitmapContextCreate. 
    334334        // I guess it is safer to handle 16 bit grayscale image as 32-bit RGBA image. 
    335335        // It works at least on FlightGear 
     
    342342            pixel_format = GL_BGRA_EXT; 
    343343            data_type = GL_UNSIGNED_INT_8_8_8_8_REV; 
    344              
     344 
    345345            bytes_per_row = the_width*4; 
    346346//            color_space = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB); 
     
    352352#else 
    353353            bitmap_info = kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Little; /* XRGB Little Endian */ 
    354 #endif  
     354#endif 
    355355            break; 
    356356        } 
     
    363363 
    364364    } 
    365      
     365 
    366366    // Sets up a context to be drawn to with image_data as the area to be drawn to 
    367367    CGContextRef bitmap_context = CGBitmapContextCreate( 
     
    374374        bitmap_info 
    375375    ); 
    376      
     376 
    377377    // Draws the image into the context's image_data 
    378378    CGContextDrawImage(bitmap_context, the_rect, image_ref); 
     
    380380    CGContextRelease(bitmap_context); 
    381381 
    382     //  
     382    // 
    383383    // Reverse the premultiplied alpha for avoiding unexpected darker edges 
    384384    // by Tatsuhiro Nishioka (based on SDL's workaround on the similar issue) 
    385385    // http://bugzilla.libsdl.org/show_bug.cgi?id=868 
    386     //  
     386    // 
    387387    if (bits_per_pixel > 8 && (bitmap_info & kCGBitmapAlphaInfoMask) == kCGImageAlphaPremultipliedFirst) { 
    388388        int i, j; 
    389389        GLubyte *pixels = (GLubyte *)image_data; 
    390390        for (i = the_height * the_width; i--; ) { 
    391              
     391 
    392392#if __BIG_ENDIAN__ 
    393393            // That value is a temporary one and only needed for endianess conversion 
    394394            GLuint *value = (GLuint *)pixels; 
    395             //  
     395            // 
    396396            // swap endian of each pixel for avoiding weird colors on ppc macs 
    397397            // by Tatsuhiro Nishioka 
    398             // FIXME: I've tried many combinations of pixel_format, internal_format, and data_type  
     398            // FIXME: I've tried many combinations of pixel_format, internal_format, and data_type 
    399399            // but none worked well. Therefore I tried endian swapping, which seems working with gif,png,tiff,tga,and psd. 
    400             // (for grayscaled tga and non-power-of-two tga, I can't guarantee since test images (made with Gimp)  
     400            // (for grayscaled tga and non-power-of-two tga, I can't guarantee since test images (made with Gimp) 
    401401            // get corrupted on Preview.app ... 
    402402            *value = ((*value) >> 24) | (((*value) << 8) & 0x00FF0000) | (((*value) >> 8) & 0x0000FF00) | ((*value) << 24); 
     
    420420    data_type = GL_UNSIGNED_BYTE; 
    421421    osg::Image* osg_image = new osg::Image; 
    422      
     422 
    423423    osg_image->setImage( 
    424424        the_width, 
     
    460460     */ 
    461461    size_t target_bytes_per_row; 
    462       
     462 
    463463    CGColorSpaceRef color_space; 
    464464    CGBitmapInfo bitmap_info; 
     
    477477     * and invert the data. 
    478478     */ 
    479     vImage_Buffer vimage_buffer_in =  
     479    vImage_Buffer vimage_buffer_in = 
    480480    { 
    481481        (void*)osg_image.data(), // need to override const, but we don't modify the data so it's safe 
     
    492492        image_width, 
    493493        0 // will fill-in in switch 
    494     };     
     494    }; 
    495495    vImage_Error vimage_error_flag; 
    496496 
     
    507507                return NULL; 
    508508            } 
    509              
     509 
    510510            //    out_image_data = calloc(target_bytes_per_row, image_height); 
    511             out_image_data = malloc(target_bytes_per_row * image_height);             
     511            out_image_data = malloc(target_bytes_per_row * image_height); 
    512512            if(NULL == out_image_data) 
    513513            { 
     
    532532                CGColorSpaceRelease(color_space); 
    533533                return NULL; 
    534             }             
     534            } 
    535535 
    536536 
     
    545545            // colorSpace=NULL is for alpha only 
    546546            color_space = NULL; 
    547              
     547 
    548548            //    out_image_data = calloc(target_bytes_per_row, image_height); 
    549             out_image_data = malloc(target_bytes_per_row * image_height);             
     549            out_image_data = malloc(target_bytes_per_row * image_height); 
    550550            if(NULL == out_image_data) 
    551551            { 
     
    568568                free(out_image_data); 
    569569                return NULL; 
    570             }             
     570            } 
    571571 
    572572 
     
    591591                return NULL; 
    592592            } 
    593              
     593 
    594594            //    out_image_data = calloc(target_bytes_per_row, image_height); 
    595             out_image_data = malloc(target_bytes_per_row * image_height);             
     595            out_image_data = malloc(target_bytes_per_row * image_height); 
    596596            if(NULL == out_image_data) 
    597597            { 
     
    631631                CGColorSpaceRelease(color_space); 
    632632                return NULL; 
    633             }             
    634              
     633            } 
     634 
    635635            break; 
    636636        } 
     
    646646            } 
    647647            //    out_image_data = calloc(target_bytes_per_row, image_height); 
    648             out_image_data = malloc(target_bytes_per_row * image_height);             
     648            out_image_data = malloc(target_bytes_per_row * image_height); 
    649649            if(NULL == out_image_data) 
    650650            { 
     
    667667                CGColorSpaceRelease(color_space); 
    668668                return NULL; 
    669             }             
     669            } 
    670670            break; 
    671671        } 
     
    678678#else 
    679679                bitmap_info = kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Little; /* XRGB Little Endian */ 
    680 #endif  
     680#endif 
    681681            } 
    682682            else 
     
    694694            } 
    695695            //    out_image_data = calloc(target_bytes_per_row, image_height); 
    696             out_image_data = malloc(target_bytes_per_row * image_height);             
     696            out_image_data = malloc(target_bytes_per_row * image_height); 
    697697            if(NULL == out_image_data) 
    698698            { 
     
    715715                CGColorSpaceRelease(color_space); 
    716716                return NULL; 
    717             }             
     717            } 
    718718            break; 
    719719        } 
     
    745745        return NULL; 
    746746    } 
    747      
     747 
    748748 
    749749    /* Make an image out of our bitmap; does a cheap vm_copy of the bitmap */ 
     
    782782        return NULL; 
    783783    } 
    784      
     784 
    785785    /* Create a CFURL from a CFString */ 
    786786    the_url = CFURLCreateWithFileSystemPath( 
    787         NULL,  
     787        NULL, 
    788788        cf_string, 
    789789        kCFURLPOSIXPathStyle, 
    790790        false 
    791791    ); 
    792      
     792 
    793793    /* Don't need the CFString any more (error or not) */ 
    794794    CFRelease(cf_string); 
    795      
     795 
    796796    if(!the_url) 
    797797    { 
    798798        return NULL; 
    799799    } 
    800      
     800 
    801801    if(the_options) 
    802802    { 
     
    806806        { 
    807807            // Not handled: The user could do something stupid and specify both PNG and JPEG options. 
    808              
     808 
    809809            if(opt=="PNG_COMPRESSION") 
    810810            { 
     
    813813                int level; 
    814814                iss >> level; 
    815                                  
     815 
    816816            } 
    817817            else if(opt=="JPEG_QUALITY") 
     
    827827        } 
    828828    } 
    829      
     829 
    830830 
    831831    CFStringRef path_extension = CFURLCopyPathExtension(the_url); 
     
    859859    } 
    860860 
    861                                                        
     861 
    862862    dest_ref =  CGImageDestinationCreateWithURL( 
    863         the_url,  
    864         uti_type,  
     863        the_url, 
     864        uti_type, 
    865865        1, // image file will contain only one image 
    866866        NULL 
    867867    ); 
    868868 
    869      
     869 
    870870    CFRelease(uti_type); 
    871871    CFRelease(the_url); 
     
    879879        CFNumberRef the_values[1]; 
    880880        CFDictionaryRef the_dict; 
    881                  
     881 
    882882        the_keys[0] = kCGImageDestinationLossyCompressionQuality; 
    883883        the_values[0] = CFNumberCreate( 
     
    886886            &compression_quality 
    887887        ); 
    888          
     888 
    889889        the_dict = CFDictionaryCreate(NULL, (const void**)&the_keys, (const void**)&the_values, 1, &kCFCopyStringDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); 
    890890        CFRelease(the_values[0]); 
     
    892892        // Now that we have the dict, actually set the property. 
    893893        CGImageDestinationSetProperties(dest_ref, the_dict); 
    894          
     894 
    895895        CFRelease(the_dict); 
    896896    } 
     
    909909    bool found_jpeg_option = false; 
    910910    float compression_quality = 1.0f; 
    911      
     911 
    912912    CGDataConsumerCallbacks consumer_callbacks = 
    913913    { 
     
    915915        MyConsumerReleaseInfoCallback 
    916916    }; 
    917      
     917 
    918918    CGDataConsumerRef data_consumer = CGDataConsumerCreate(&fout, &consumer_callbacks); 
    919919 
     
    925925        { 
    926926            // Not handled: The user could do something stupid and specify both PNG and JPEG options. 
    927              
     927 
    928928            if(opt=="PNG_COMPRESSION") 
    929929            { 
     
    932932                int level; 
    933933                iss >> level; 
    934                  
     934 
    935935            } 
    936936            else if(opt=="JPEG_QUALITY") 
     
    946946        } 
    947947    } 
    948      
     948 
    949949 
    950950    if(found_jpeg_option) 
     
    964964        ); 
    965965    } 
    966      
     966 
    967967 
    968968    // If we had a way of hinting at what the data type is, we could 
     
    974974        NULL 
    975975    ); 
    976      
     976 
    977977    CGDataConsumerRelease(data_consumer); 
    978978    CFRelease(uti_type); 
    979      
    980      
     979 
     980 
    981981    // Not handled: The user could do something stupid and specify both PNG and JPEG options. 
    982982    if(found_jpeg_option) 
     
    986986        CFNumberRef the_values[1]; 
    987987        CFDictionaryRef the_dict; 
    988          
     988 
    989989        the_keys[0] = kCGImageDestinationLossyCompressionQuality; 
    990990        the_values[0] = CFNumberCreate( 
     
    993993                                       &compression_quality 
    994994                                       ); 
    995          
     995 
    996996        the_dict = CFDictionaryCreate(NULL, (const void**)&the_keys, (const void**)&the_values, 1, &kCFCopyStringDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); 
    997997        CFRelease(the_values[0]); 
    998          
     998 
    999999        // Now that we have the dict, actually set the property. 
    10001000        CGImageDestinationSetProperties(dest_ref, the_dict); 
    1001          
     1001 
    10021002        CFRelease(the_dict); 
    10031003    } 
    1004      
     1004 
    10051005    return dest_ref; 
    10061006} 
     
    10181018    { 
    10191019 
    1020          supportsExtension("jpg",   "jpg image file");  
     1020         supportsExtension("jpg",   "jpg image file"); 
    10211021         supportsExtension("jpeg",  "jpeg image file"); 
    10221022         supportsExtension("jpe",   "jpe image file"); 
    10231023         supportsExtension("jp2",   "jp2 image file"); 
    1024          supportsExtension("tiff",  "tiff image file");  
    1025          supportsExtension("tif",   "tif image file");                
     1024         supportsExtension("tiff",  "tiff image file"); 
     1025         supportsExtension("tif",   "tif image file"); 
    10261026         supportsExtension("gif",   "gif image file"); 
    10271027         supportsExtension("png",   "png image file"); 
     
    10361036         supportsExtension("targa", "targa image file"); 
    10371037         supportsExtension("psd",   "psd image file"); 
    1038           
     1038 
    10391039         supportsExtension("pdf",   "pdf image file"); 
    10401040         supportsExtension("eps",   "eps image file"); 
     
    10431043         supportsExtension("epsi",  "epsi image file"); 
    10441044         supportsExtension("ps",    "postscript image file"); 
    1045           
     1045 
    10461046         supportsExtension("dng",   "dng image file"); 
    10471047         supportsExtension("cr2",   "cr2 image file"); 
     
    10841084       // http://developer.apple.com/documentation/Carbon/Conceptual/understanding_utis/utilist/chapter_4_section_1.html 
    10851085      return 
    1086          osgDB::equalCaseInsensitive(extension,"jpg") ||  
     1086         osgDB::equalCaseInsensitive(extension,"jpg") || 
    10871087         osgDB::equalCaseInsensitive(extension,"jpeg") || 
    10881088         osgDB::equalCaseInsensitive(extension,"jpe") || 
    10891089         osgDB::equalCaseInsensitive(extension,"jp2") || 
    1090          osgDB::equalCaseInsensitive(extension,"tiff") ||  
    1091          osgDB::equalCaseInsensitive(extension,"tif") ||                
     1090         osgDB::equalCaseInsensitive(extension,"tiff") || 
     1091         osgDB::equalCaseInsensitive(extension,"tif") || 
    10921092         osgDB::equalCaseInsensitive(extension,"gif") || 
    10931093         osgDB::equalCaseInsensitive(extension,"png") || 
     
    11021102         osgDB::equalCaseInsensitive(extension,"targa") || 
    11031103         osgDB::equalCaseInsensitive(extension,"psd") || 
    1104           
     1104 
    11051105         osgDB::equalCaseInsensitive(extension,"pdf") || 
    11061106         osgDB::equalCaseInsensitive(extension,"eps") || 
     
    11091109         osgDB::equalCaseInsensitive(extension,"epsi") || 
    11101110         osgDB::equalCaseInsensitive(extension,"ps") || 
    1111           
     1111 
    11121112         osgDB::equalCaseInsensitive(extension,"dng") || 
    11131113         osgDB::equalCaseInsensitive(extension,"cr2") || 
     
    11361136 
    11371137 
    1138      
     1138 
    11391139    ReadResult readImageStream(std::istream& fin) const 
    11401140    { 
     
    11451145        // Create an osg::Image from the CGImageRef. 
    11461146        osg::Image* osg_image = CreateOSGImageFromCGImage(cg_image_ref); 
    1147      
     1147 
    11481148        CFRelease(cg_image_ref); 
    11491149        return osg_image; 
     
    11551155        return read_result; 
    11561156    } 
    1157      
     1157 
    11581158    ReadResult readImageFile(const std::string& file_name) const 
    11591159    { 
    11601160        OSG_INFO << "imageio readImageFile: " << file_name << std::endl; 
    1161          
     1161 
    11621162        // Call ImageIO to load the image. 
    11631163        CGImageRef cg_image_ref = CreateCGImageFromFile(file_name.c_str()); 
     
    11661166        // Create an osg::Image from the CGImageRef. 
    11671167        osg::Image* osg_image = CreateOSGImageFromCGImage(cg_image_ref); 
    1168      
     1168 
    11691169        CFRelease(cg_image_ref); 
    11701170 
     
    11831183        ReadResult read_result = readImageFile(full_file_name); 
    11841184#else 
    1185         // Only here to help test istream backend. The file version is better because  
     1185        // Only here to help test istream backend. The file version is better because 
    11861186        // the filenname.extension could potentially be used by ImageIO to hint what the format type is. 
    11871187        osgDB::ifstream istream(full_file_name.c_str(), std::ios::in | std::ios::binary); 
     
    12091209        CGImageDestinationRef cg_dest_ref = CreateCGImageDestinationFromDataStream(fout, the_options); 
    12101210        if (NULL == cg_dest_ref) return WriteResult::ERROR_IN_WRITING_FILE; 
    1211          
     1211 
    12121212        CGImageRef cg_image_ref = CreateCGImageFromOSGData(osg_image); 
    12131213        if(NULL == cg_image_ref) 
     
    12161216            return WriteResult::ERROR_IN_WRITING_FILE; 
    12171217        } 
    1218          
     1218 
    12191219        CGImageDestinationAddImage(cg_dest_ref, cg_image_ref, NULL); 
    12201220        if(CGImageDestinationFinalize(cg_dest_ref)) 
     
    12261226            ret_val = WriteResult::ERROR_IN_WRITING_FILE; 
    12271227        } 
    1228          
     1228 
    12291229        CFRelease(cg_image_ref); 
    12301230        CFRelease(cg_dest_ref); 
    1231          
    1232         return WriteResult::FILE_SAVED;     
    1233     } 
    1234          
     1231 
     1232        return WriteResult::FILE_SAVED; 
     1233    } 
     1234 
    12351235    virtual WriteResult writeImage(const osg::Image& osg_image, std::ostream& fout, const osgDB::ReaderWriter::Options* the_options) const 
    12361236    { 
     
    12681268            ret_val = WriteResult::ERROR_IN_WRITING_FILE; 
    12691269        } 
    1270          
     1270 
    12711271        CFRelease(cg_image_ref); 
    12721272        CFRelease(cg_dest_ref); 
    1273          
     1273 
    12741274        return WriteResult::FILE_SAVED; 
    12751275    } 
     
    12921292        return writeImageFile(osg_image, full_file_name, the_options); 
    12931293#else 
    1294         // Only here to help test ostream backend. The file version is better because  
     1294        // Only here to help test ostream backend. The file version is better because 
    12951295        // the filenname.extension could potentially be used by ImageIO to hint what the format type is. 
    12961296        osgDB::ofstream fout(file_name.c_str(), std::ios::out | std::ios::binary); 
    12971297        if(!fout) return WriteResult::ERROR_IN_WRITING_FILE; 
    12981298        return writeImage(osg_image, fout, the_options); 
    1299 #endif         
     1299#endif 
    13001300    } 
    13011301