Ran script to remove trailing spaces and tabs
This commit is contained in:
@@ -98,7 +98,7 @@ CGImageRef CreateCGImageFromDataStream(std::istream& fin)
|
||||
);
|
||||
source_ref = CGImageSourceCreateWithData(the_cf_data, NULL);
|
||||
*/
|
||||
|
||||
|
||||
CGDataProviderSequentialCallbacks provider_callbacks =
|
||||
{
|
||||
0,
|
||||
@@ -107,44 +107,44 @@ CGImageRef CreateCGImageFromDataStream(std::istream& fin)
|
||||
MyProviderRewindCallback,
|
||||
MyProviderReleaseInfoCallback
|
||||
};
|
||||
|
||||
|
||||
CGDataProviderRef data_provider = CGDataProviderCreateSequential(&fin, &provider_callbacks);
|
||||
|
||||
|
||||
// If we had a way of hinting at what the data type is, we could
|
||||
// pass this hint in the second parameter.
|
||||
source_ref = CGImageSourceCreateWithDataProvider(data_provider, NULL);
|
||||
|
||||
|
||||
CGDataProviderRelease(data_provider);
|
||||
|
||||
|
||||
|
||||
|
||||
if(!source_ref)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
image_ref = CGImageSourceCreateImageAtIndex(source_ref, 0, NULL);
|
||||
|
||||
|
||||
/* Don't need the SourceRef any more (error or not) */
|
||||
CFRelease(source_ref);
|
||||
|
||||
|
||||
return image_ref;
|
||||
}
|
||||
|
||||
static NSString* toNSString(const std::string& text, NSStringEncoding nsse)
|
||||
{
|
||||
NSString* nstr = nil;
|
||||
|
||||
|
||||
if (!text.empty())
|
||||
{
|
||||
nstr = [NSString stringWithCString:text.c_str() encoding:nsse];
|
||||
//nstr = [NSString stringWithUTF8String:text.c_str()];// encoding:nsse]
|
||||
}
|
||||
|
||||
|
||||
if (nstr == nil)
|
||||
{
|
||||
nstr = @"";
|
||||
}
|
||||
|
||||
|
||||
return nstr;
|
||||
}
|
||||
|
||||
@@ -166,10 +166,10 @@ osg::Image* ReadCoreGraphicsImageFromFile(std::string file)
|
||||
//std::string strPath = osgDB::getFilePath(file);
|
||||
//std::string strName = osgDB::getStrippedName(file);
|
||||
//std::string strFile = strPath + "/" + strName;
|
||||
|
||||
//NSString* path = [NSString stringWithCString:strName.c_str() encoding:NSUTF8StringEncoding];
|
||||
//NSString* ext = [NSString stringWithCString:strExt.c_str() encoding:NSUTF8StringEncoding];
|
||||
|
||||
|
||||
//NSString* path = [NSString stringWithCString:strName.c_str() encoding:NSUTF8StringEncoding];
|
||||
//NSString* ext = [NSString stringWithCString:strExt.c_str() encoding:NSUTF8StringEncoding];
|
||||
|
||||
//CGImageRef textureImage = [UIImage imageNamed:path].CGImage;
|
||||
//CGImageRef textureImage = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:path ofType:ext]].CGImage;
|
||||
NSString* path = [NSString stringWithCString:file.c_str() encoding:NSUTF8StringEncoding];
|
||||
@@ -186,8 +186,8 @@ osg::Image* ReadCoreGraphicsImageFromFile(std::string file)
|
||||
[pool release];
|
||||
return NULL;
|
||||
}
|
||||
|
||||
size_t texWidth = CGImageGetWidth(textureImage);
|
||||
|
||||
size_t texWidth = CGImageGetWidth(textureImage);
|
||||
size_t texHeight = CGImageGetHeight(textureImage);
|
||||
GLubyte *textureData = (GLubyte *)malloc(texWidth * texHeight * 4);
|
||||
if (!textureData) {
|
||||
@@ -204,7 +204,7 @@ osg::Image* ReadCoreGraphicsImageFromFile(std::string file)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CGContextRef textureContext = CGBitmapContextCreate(textureData,
|
||||
CGContextRef textureContext = CGBitmapContextCreate(textureData,
|
||||
texWidth, texHeight,
|
||||
8, texWidth * 4,
|
||||
csref,
|
||||
@@ -216,13 +216,13 @@ osg::Image* ReadCoreGraphicsImageFromFile(std::string file)
|
||||
[pool release];
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
//copy into texturedata
|
||||
CGContextDrawImage(textureContext,
|
||||
CGRectMake(0.0f, 0.0f, (float)texWidth, (float)texHeight),
|
||||
textureImage);
|
||||
CGContextRelease(textureContext);
|
||||
|
||||
|
||||
//create the osg image
|
||||
int s = texWidth;
|
||||
int t = texHeight;
|
||||
@@ -233,19 +233,19 @@ osg::Image* ReadCoreGraphicsImageFromFile(std::string file)
|
||||
GL_UNSIGNED_BYTE,
|
||||
textureData,
|
||||
osg::Image::USE_MALLOC_FREE);
|
||||
|
||||
|
||||
//flip vertical
|
||||
image->flipVertical();
|
||||
|
||||
//
|
||||
|
||||
//
|
||||
// Reverse the premultiplied alpha for avoiding unexpected darker edges
|
||||
// by Tatsuhiro Nishioka (based on SDL's workaround on the similar issue)
|
||||
// http://bugzilla.libsdl.org/show_bug.cgi?id=868
|
||||
//
|
||||
//
|
||||
int i, j;
|
||||
GLubyte *pixels = (GLubyte *)image->data();
|
||||
for (i = image->t() * image->s(); i--; ) {
|
||||
|
||||
|
||||
GLubyte alpha = pixels[3];
|
||||
if (alpha && (alpha < 255)) {
|
||||
for (j = 0; j < 3; ++j) {
|
||||
@@ -268,7 +268,7 @@ osg::Image* CreateOSGImageFromCGImage(CGImageRef textureImage)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
size_t texWidth = CGImageGetWidth(textureImage);
|
||||
size_t texWidth = CGImageGetWidth(textureImage);
|
||||
size_t texHeight = CGImageGetHeight(textureImage);
|
||||
|
||||
GLubyte *textureData = (GLubyte *)malloc(texWidth * texHeight * 4);
|
||||
@@ -277,7 +277,7 @@ osg::Image* CreateOSGImageFromCGImage(CGImageRef textureImage)
|
||||
[pool release];
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
CGColorSpaceRef csref = CGColorSpaceCreateDeviceRGB();
|
||||
if (!csref) {
|
||||
NSLog(@"imageio: failed to create CGColorSpaceRef.\n");
|
||||
@@ -286,7 +286,7 @@ osg::Image* CreateOSGImageFromCGImage(CGImageRef textureImage)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CGContextRef textureContext = CGBitmapContextCreate(textureData,
|
||||
CGContextRef textureContext = CGBitmapContextCreate(textureData,
|
||||
texWidth, texHeight,
|
||||
8, texWidth * 4,
|
||||
csref,
|
||||
@@ -298,15 +298,15 @@ osg::Image* CreateOSGImageFromCGImage(CGImageRef textureImage)
|
||||
[pool release];
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
//copy into texturedata
|
||||
CGContextDrawImage(textureContext,
|
||||
CGRectMake(0.0f, 0.0f, (float)texWidth, (float)texHeight),
|
||||
textureImage);
|
||||
CGContextFlush(textureContext);
|
||||
CGContextFlush(textureContext);
|
||||
CGContextRelease(textureContext);
|
||||
|
||||
|
||||
|
||||
|
||||
//create the osg image
|
||||
int s = texWidth;
|
||||
int t = texHeight;
|
||||
@@ -317,21 +317,21 @@ osg::Image* CreateOSGImageFromCGImage(CGImageRef textureImage)
|
||||
GL_UNSIGNED_BYTE,
|
||||
textureData,
|
||||
osg::Image::USE_MALLOC_FREE);
|
||||
|
||||
|
||||
//flip vertical
|
||||
image->flipVertical();
|
||||
|
||||
//
|
||||
|
||||
//
|
||||
// Reverse the premultiplied alpha for avoiding unexpected darker edges
|
||||
// by Tatsuhiro Nishioka (based on SDL's workaround on the similar issue)
|
||||
// http://bugzilla.libsdl.org/show_bug.cgi?id=868
|
||||
//
|
||||
|
||||
|
||||
//
|
||||
|
||||
|
||||
int i, j;
|
||||
GLubyte *pixels = (GLubyte *)image->data();
|
||||
for (i = image->t() * image->s(); i--; ) {
|
||||
|
||||
|
||||
GLubyte alpha = pixels[3];
|
||||
if (alpha && (alpha < 255)) {
|
||||
for (j = 0; j < 3; ++j) {
|
||||
@@ -351,13 +351,13 @@ class ReaderWriterImageIO : public osgDB::ReaderWriter
|
||||
public:
|
||||
ReaderWriterImageIO()
|
||||
{
|
||||
|
||||
supportsExtension("jpg", "jpg image file");
|
||||
|
||||
supportsExtension("jpg", "jpg image file");
|
||||
supportsExtension("jpeg", "jpeg image file");
|
||||
supportsExtension("jpe", "jpe image file");
|
||||
supportsExtension("jp2", "jp2 image file");
|
||||
supportsExtension("tiff", "tiff image file");
|
||||
supportsExtension("tif", "tif image file");
|
||||
supportsExtension("tiff", "tiff image file");
|
||||
supportsExtension("tif", "tif image file");
|
||||
supportsExtension("gif", "gif image file");
|
||||
supportsExtension("png", "png image file");
|
||||
supportsExtension("pict", "pict image file");
|
||||
@@ -370,14 +370,14 @@ public:
|
||||
supportsExtension("tga", "tga image file");
|
||||
supportsExtension("targa", "targa image file");
|
||||
supportsExtension("psd", "psd image file");
|
||||
|
||||
|
||||
supportsExtension("pdf", "pdf image file");
|
||||
supportsExtension("eps", "eps image file");
|
||||
supportsExtension("epi", "epi image file");
|
||||
supportsExtension("epsf", "epsf image file");
|
||||
supportsExtension("epsi", "epsi image file");
|
||||
supportsExtension("ps", "postscript image file");
|
||||
|
||||
|
||||
supportsExtension("dng", "dng image file");
|
||||
supportsExtension("cr2", "cr2 image file");
|
||||
supportsExtension("crw", "crw image file");
|
||||
@@ -399,13 +399,13 @@ public:
|
||||
supportsExtension("srf", "srf image file");
|
||||
supportsExtension("cur", "cur image file");
|
||||
supportsExtension("xbm", "xbm image file");
|
||||
|
||||
|
||||
supportsExtension("raw", "raw image file");
|
||||
}
|
||||
|
||||
|
||||
virtual const char* className() const { return "Mac OS X ImageIO based Image Reader/Writer"; }
|
||||
|
||||
|
||||
|
||||
|
||||
virtual bool acceptsExtension(const std::string& extension) const
|
||||
{
|
||||
// ImageIO speaks in UTIs.
|
||||
@@ -418,12 +418,12 @@ public:
|
||||
// Apple's UTI guide:
|
||||
// http://developer.apple.com/documentation/Carbon/Conceptual/understanding_utis/utilist/chapter_4_section_1.html
|
||||
return
|
||||
osgDB::equalCaseInsensitive(extension,"jpg") ||
|
||||
osgDB::equalCaseInsensitive(extension,"jpg") ||
|
||||
osgDB::equalCaseInsensitive(extension,"jpeg") ||
|
||||
osgDB::equalCaseInsensitive(extension,"jpe") ||
|
||||
osgDB::equalCaseInsensitive(extension,"jp2") ||
|
||||
osgDB::equalCaseInsensitive(extension,"tiff") ||
|
||||
osgDB::equalCaseInsensitive(extension,"tif") ||
|
||||
osgDB::equalCaseInsensitive(extension,"tiff") ||
|
||||
osgDB::equalCaseInsensitive(extension,"tif") ||
|
||||
osgDB::equalCaseInsensitive(extension,"gif") ||
|
||||
osgDB::equalCaseInsensitive(extension,"png") ||
|
||||
osgDB::equalCaseInsensitive(extension,"pict") ||
|
||||
@@ -436,14 +436,14 @@ public:
|
||||
osgDB::equalCaseInsensitive(extension,"tga") ||
|
||||
osgDB::equalCaseInsensitive(extension,"targa") ||
|
||||
osgDB::equalCaseInsensitive(extension,"psd") ||
|
||||
|
||||
|
||||
osgDB::equalCaseInsensitive(extension,"pdf") ||
|
||||
osgDB::equalCaseInsensitive(extension,"eps") ||
|
||||
osgDB::equalCaseInsensitive(extension,"epi") ||
|
||||
osgDB::equalCaseInsensitive(extension,"epsf") ||
|
||||
osgDB::equalCaseInsensitive(extension,"epsi") ||
|
||||
osgDB::equalCaseInsensitive(extension,"ps") ||
|
||||
|
||||
|
||||
osgDB::equalCaseInsensitive(extension,"dng") ||
|
||||
osgDB::equalCaseInsensitive(extension,"cr2") ||
|
||||
osgDB::equalCaseInsensitive(extension,"crw") ||
|
||||
@@ -465,35 +465,35 @@ public:
|
||||
osgDB::equalCaseInsensitive(extension,"srf") ||
|
||||
osgDB::equalCaseInsensitive(extension,"cur") ||
|
||||
osgDB::equalCaseInsensitive(extension,"xbm") ||
|
||||
|
||||
|
||||
osgDB::equalCaseInsensitive(extension,"raw");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
ReadResult readImageStream(std::istream& fin) const
|
||||
{
|
||||
// Call ImageIO to load the image.
|
||||
CGImageRef cg_image_ref = CreateCGImageFromDataStream(fin);
|
||||
if (NULL == cg_image_ref) return ReadResult::FILE_NOT_FOUND;
|
||||
|
||||
|
||||
// Create an osg::Image from the CGImageRef.
|
||||
osg::Image* osg_image = CreateOSGImageFromCGImage(cg_image_ref);
|
||||
|
||||
|
||||
CFRelease(cg_image_ref);
|
||||
return osg_image;
|
||||
}
|
||||
|
||||
|
||||
virtual ReadResult readImage(std::istream& fin, const osgDB::ReaderWriter::Options* the_options = NULL) const
|
||||
{
|
||||
ReadResult read_result = readImageStream(fin);
|
||||
return read_result;
|
||||
}
|
||||
|
||||
|
||||
ReadResult readImageFile(const std::string& file_name) const
|
||||
{
|
||||
//osg::notify(osg::INFO) << "imageio readImageFile: " << file_name << std::endl;
|
||||
|
||||
|
||||
// Create an osg::Image from the CGImageRef.
|
||||
osg::Image* osg_image = ReadCoreGraphicsImageFromFile(file_name);
|
||||
|
||||
@@ -511,7 +511,7 @@ public:
|
||||
#if 1
|
||||
ReadResult read_result = readImageFile(full_file_name);
|
||||
#else
|
||||
// Only here to help test istream backend. The file version is better because
|
||||
// Only here to help test istream backend. The file version is better because
|
||||
// the filenname.extension could potentially be used by ImageIO to hint what the format type is.
|
||||
std::ifstream istream(full_file_name.c_str(), std::ios::in | std::ios::binary);
|
||||
if(!istream) return ReadResult::FILE_NOT_HANDLED;
|
||||
@@ -530,7 +530,7 @@ public:
|
||||
{
|
||||
WriteResult ret_val = WriteResult::ERROR_IN_WRITING_FILE;
|
||||
|
||||
return WriteResult::FILE_SAVED;
|
||||
return WriteResult::FILE_SAVED;
|
||||
}
|
||||
|
||||
virtual WriteResult writeImage(const osg::Image& osg_image, std::ostream& fout, const osgDB::ReaderWriter::Options* the_options) const
|
||||
@@ -542,7 +542,7 @@ public:
|
||||
WriteResult writeImageFile(const osg::Image& osg_image, const std::string& full_file_name, const osgDB::ReaderWriter::Options* the_options) const
|
||||
{
|
||||
WriteResult ret_val = WriteResult::ERROR_IN_WRITING_FILE;
|
||||
|
||||
|
||||
return WriteResult::FILE_SAVED;
|
||||
}
|
||||
|
||||
@@ -557,12 +557,12 @@ public:
|
||||
full_file_name = file_name;
|
||||
return writeImageFile(osg_image, full_file_name, the_options);
|
||||
#else
|
||||
// Only here to help test ostream backend. The file version is better because
|
||||
// Only here to help test ostream backend. The file version is better because
|
||||
// the filenname.extension could potentially be used by ImageIO to hint what the format type is.
|
||||
std::ofstream fout(file_name.c_str(), std::ios::out | std::ios::binary);
|
||||
if(!fout) return WriteResult::ERROR_IN_WRITING_FILE;
|
||||
return writeImage(osg_image, fout, the_options);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user