aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra')
-rw-r--r--linden/indra/llimage/llimage.h6
-rw-r--r--linden/indra/llwindow/llwindowmacosx-objc.mm45
-rw-r--r--linden/indra/newview/floaterlocalassetbrowse.cpp4
-rw-r--r--linden/indra/newview/floaterlocalassetbrowse.h4
-rw-r--r--linden/indra/newview/llfilepicker.cpp4
-rw-r--r--linden/indra/newview/llfloaterimagepreview.cpp10
-rw-r--r--linden/indra/newview/llviewermenufile.cpp32
7 files changed, 90 insertions, 15 deletions
diff --git a/linden/indra/llimage/llimage.h b/linden/indra/llimage/llimage.h
index 2bc62fb..fd8d128 100644
--- a/linden/indra/llimage/llimage.h
+++ b/linden/indra/llimage/llimage.h
@@ -73,7 +73,13 @@ typedef enum e_image_codec
73 IMG_CODEC_JPEG = 5, 73 IMG_CODEC_JPEG = 5,
74 IMG_CODEC_DXT = 6, 74 IMG_CODEC_DXT = 6,
75 IMG_CODEC_PNG = 7, 75 IMG_CODEC_PNG = 7,
76#ifdef LL_DARWIN
77 IMG_CODEC_PSD = 8,
78 IMG_CODEC_TIFF = 9,
79 IMG_CODEC_EOF = 10
80#else
76 IMG_CODEC_EOF = 8 81 IMG_CODEC_EOF = 8
82#endif
77} EImageCodec; 83} EImageCodec;
78 84
79//============================================================================ 85//============================================================================
diff --git a/linden/indra/llwindow/llwindowmacosx-objc.mm b/linden/indra/llwindow/llwindowmacosx-objc.mm
index 5f33764..e961070 100644
--- a/linden/indra/llwindow/llwindowmacosx-objc.mm
+++ b/linden/indra/llwindow/llwindowmacosx-objc.mm
@@ -49,7 +49,7 @@ BOOL decodeImageQuartz(const UInt8* data, int len, LLImageRaw *raw_image)
49 CFDataRef theData = CFDataCreate(kCFAllocatorDefault, data, len); 49 CFDataRef theData = CFDataCreate(kCFAllocatorDefault, data, len);
50 CGImageSourceRef srcRef = CGImageSourceCreateWithData(theData, NULL); 50 CGImageSourceRef srcRef = CGImageSourceCreateWithData(theData, NULL);
51 CGImageRef image_ref = CGImageSourceCreateImageAtIndex(srcRef, 0, NULL); 51 CGImageRef image_ref = CGImageSourceCreateImageAtIndex(srcRef, 0, NULL);
52 52 CFShow(CGImageGetColorSpace(image_ref));
53 size_t width = CGImageGetWidth(image_ref); 53 size_t width = CGImageGetWidth(image_ref);
54 size_t height = CGImageGetHeight(image_ref); 54 size_t height = CGImageGetHeight(image_ref);
55 size_t comps = CGImageGetBitsPerPixel(image_ref) / 8; 55 size_t comps = CGImageGetBitsPerPixel(image_ref) / 8;
@@ -58,29 +58,44 @@ BOOL decodeImageQuartz(const UInt8* data, int len, LLImageRaw *raw_image)
58 UInt8* bitmap = (UInt8*)CFDataGetBytePtr(result); 58 UInt8* bitmap = (UInt8*)CFDataGetBytePtr(result);
59 59
60 CGImageAlphaInfo format = CGImageGetAlphaInfo(image_ref); 60 CGImageAlphaInfo format = CGImageGetAlphaInfo(image_ref);
61 if (format & kCGImageAlphaPremultipliedFirst) 61 if (format != kCGImageAlphaNone)
62 { 62 {
63 vImage_Buffer vb; 63 vImage_Buffer vb;
64 vb.data = bitmap; 64 vb.data = bitmap;
65 vb.height = height; 65 vb.height = height;
66 vb.width = width; 66 vb.width = width;
67 vb.rowBytes = bytes_per_row; 67 vb.rowBytes = bytes_per_row;
68 llinfos << "Unpremultiplying ARGB888" << llendl; 68
69 vImageUnpremultiplyData_ARGB8888(&vb, &vb, 0); 69 if (format & kCGImageAlphaPremultipliedFirst)
70 } 70 {
71 else if (format & kCGImageAlphaPremultipliedLast) 71 // Ele: ARGB -> BGRA on Intel, need to first reorder the bytes, then unpremultiply as RGBA :)
72 { 72 llinfos << "Unpremultiplying BGRA8888" << llendl;
73 vImage_Buffer vb; 73
74 vb.data = bitmap; 74 for (int i=0; i<height; i++)
75 vb.height = height; 75 {
76 vb.width = width; 76 for (int j=0; j<bytes_per_row; j+=4)
77 vb.rowBytes = bytes_per_row; 77 {
78 llinfos << "Unpremultiplying RGBA888" << llendl; 78 unsigned char tmp[4];
79 vImageUnpremultiplyData_RGBA8888(&vb, &vb, 0); 79
80 tmp[0] = bitmap[j*height+3];
81 tmp[1] = bitmap[j*height+2];
82 tmp[2] = bitmap[j*height+1];
83 tmp[3] = bitmap[j*height];
84
85 memcpy(&bitmap[j*height], &tmp, 4);
86 }
87 }
88
89 vImageUnpremultiplyData_RGBA8888(&vb, &vb, 0);
90 }
91 else if (format & kCGImageAlphaPremultipliedLast)
92 {
93 llinfos << "Unpremultiplying RGBA8888" << llendl;
94 vImageUnpremultiplyData_RGBA8888(&vb, &vb, 0);
95 }
80 } 96 }
81 97
82 raw_image->resize(width, height, comps); 98 raw_image->resize(width, height, comps);
83 llinfos << "Decoding an image of width: " << width << " and height: " << height << " and components: " << comps << llendl;
84 memcpy(raw_image->getData(), bitmap, height * bytes_per_row); 99 memcpy(raw_image->getData(), bitmap, height * bytes_per_row);
85 raw_image->verticalFlip(); 100 raw_image->verticalFlip();
86 101
diff --git a/linden/indra/newview/floaterlocalassetbrowse.cpp b/linden/indra/newview/floaterlocalassetbrowse.cpp
index 443b5bf..991d2fd 100644
--- a/linden/indra/newview/floaterlocalassetbrowse.cpp
+++ b/linden/indra/newview/floaterlocalassetbrowse.cpp
@@ -119,6 +119,10 @@ LocalBitmap::LocalBitmap(std::string fullpath)
119 else if (temp_exten == "tga") { this->extension = IMG_EXTEN_TGA; } 119 else if (temp_exten == "tga") { this->extension = IMG_EXTEN_TGA; }
120 else if (temp_exten == "jpg" || temp_exten == "jpeg") { this->extension = IMG_EXTEN_JPG; } 120 else if (temp_exten == "jpg" || temp_exten == "jpeg") { this->extension = IMG_EXTEN_JPG; }
121 else if (temp_exten == "png") { this->extension = IMG_EXTEN_PNG; } 121 else if (temp_exten == "png") { this->extension = IMG_EXTEN_PNG; }
122#ifdef LL_DARWIN
123 else if (temp_exten == "psd") { this->extension = IMG_EXTEN_PSD; }
124 else if (temp_exten == "tif" || temp_exten == "tiff") { this->extension = IMG_EXTEN_TIFF; }
125#endif
122 else { return; } // no valid extension. 126 else { return; } // no valid extension.
123 127
124 /* getting file's last modified */ 128 /* getting file's last modified */
diff --git a/linden/indra/newview/floaterlocalassetbrowse.h b/linden/indra/newview/floaterlocalassetbrowse.h
index e02a7d3..69afe98 100644
--- a/linden/indra/newview/floaterlocalassetbrowse.h
+++ b/linden/indra/newview/floaterlocalassetbrowse.h
@@ -114,6 +114,10 @@ class LocalBitmap
114 IMG_EXTEN_TGA, 114 IMG_EXTEN_TGA,
115 IMG_EXTEN_JPG, 115 IMG_EXTEN_JPG,
116 IMG_EXTEN_PNG 116 IMG_EXTEN_PNG
117#ifdef LL_DARWIN
118 ,IMG_EXTEN_PSD,
119 IMG_EXTEN_TIFF
120#endif
117 }; 121 };
118 122
119 enum bitmap_type 123 enum bitmap_type
diff --git a/linden/indra/newview/llfilepicker.cpp b/linden/indra/newview/llfilepicker.cpp
index 40b1abb..a59fa06 100644
--- a/linden/indra/newview/llfilepicker.cpp
+++ b/linden/indra/newview/llfilepicker.cpp
@@ -532,12 +532,16 @@ Boolean LLFilePicker::navOpenFilterProc(AEDesc *theItem, void *info, void *callB
532 { 532 {
533 if (fileInfo.filetype != 'JPEG' && fileInfo.filetype != 'JPG ' && 533 if (fileInfo.filetype != 'JPEG' && fileInfo.filetype != 'JPG ' &&
534 fileInfo.filetype != 'BMP ' && fileInfo.filetype != 'TGA ' && 534 fileInfo.filetype != 'BMP ' && fileInfo.filetype != 'TGA ' &&
535 fileInfo.filetype != 'TIFF' && fileInfo.filetype != 'PSD ' &&
535 fileInfo.filetype != 'BMPf' && fileInfo.filetype != 'TPIC' && 536 fileInfo.filetype != 'BMPf' && fileInfo.filetype != 'TPIC' &&
536 fileInfo.filetype != 'PNG ' && 537 fileInfo.filetype != 'PNG ' &&
537 (fileInfo.extension && (CFStringCompare(fileInfo.extension, CFSTR("jpeg"), kCFCompareCaseInsensitive) != kCFCompareEqualTo && 538 (fileInfo.extension && (CFStringCompare(fileInfo.extension, CFSTR("jpeg"), kCFCompareCaseInsensitive) != kCFCompareEqualTo &&
538 CFStringCompare(fileInfo.extension, CFSTR("jpg"), kCFCompareCaseInsensitive) != kCFCompareEqualTo && 539 CFStringCompare(fileInfo.extension, CFSTR("jpg"), kCFCompareCaseInsensitive) != kCFCompareEqualTo &&
539 CFStringCompare(fileInfo.extension, CFSTR("bmp"), kCFCompareCaseInsensitive) != kCFCompareEqualTo && 540 CFStringCompare(fileInfo.extension, CFSTR("bmp"), kCFCompareCaseInsensitive) != kCFCompareEqualTo &&
540 CFStringCompare(fileInfo.extension, CFSTR("tga"), kCFCompareCaseInsensitive) != kCFCompareEqualTo && 541 CFStringCompare(fileInfo.extension, CFSTR("tga"), kCFCompareCaseInsensitive) != kCFCompareEqualTo &&
542 CFStringCompare(fileInfo.extension, CFSTR("psd"), kCFCompareCaseInsensitive) != kCFCompareEqualTo &&
543 CFStringCompare(fileInfo.extension, CFSTR("tiff"), kCFCompareCaseInsensitive) != kCFCompareEqualTo &&
544 CFStringCompare(fileInfo.extension, CFSTR("tif"), kCFCompareCaseInsensitive) != kCFCompareEqualTo &&
541 CFStringCompare(fileInfo.extension, CFSTR("png"), kCFCompareCaseInsensitive) != kCFCompareEqualTo)) 545 CFStringCompare(fileInfo.extension, CFSTR("png"), kCFCompareCaseInsensitive) != kCFCompareEqualTo))
542 ) 546 )
543 { 547 {
diff --git a/linden/indra/newview/llfloaterimagepreview.cpp b/linden/indra/newview/llfloaterimagepreview.cpp
index 389bd5a..8142869 100644
--- a/linden/indra/newview/llfloaterimagepreview.cpp
+++ b/linden/indra/newview/llfloaterimagepreview.cpp
@@ -355,6 +355,16 @@ bool LLFloaterImagePreview::loadImage(const std::string& src_filename)
355 { 355 {
356 codec = IMG_CODEC_PNG; 356 codec = IMG_CODEC_PNG;
357 } 357 }
358#ifdef LL_DARWIN
359 else if( exten == "psd" )
360 {
361 codec = IMG_CODEC_PSD;
362 }
363 else if( exten == "tif" || exten == "tiff" )
364 {
365 codec = IMG_CODEC_TIFF;
366 }
367#endif
358 368
359 LLPointer<LLImageRaw> raw_image = new LLImageRaw; 369 LLPointer<LLImageRaw> raw_image = new LLImageRaw;
360#ifdef LL_DARWIN 370#ifdef LL_DARWIN
diff --git a/linden/indra/newview/llviewermenufile.cpp b/linden/indra/newview/llviewermenufile.cpp
index 432fcc5..1981bb9 100644
--- a/linden/indra/newview/llviewermenufile.cpp
+++ b/linden/indra/newview/llviewermenufile.cpp
@@ -640,6 +640,38 @@ void upload_new_resource(const std::string& src_filename, std::string name,
640 return; 640 return;
641 } 641 }
642 } 642 }
643#ifdef LL_DARWIN
644 else if(exten == "psd")
645 {
646 asset_type = LLAssetType::AT_TEXTURE;
647 if (!LLViewerImageList::createUploadFile(src_filename,
648 filename,
649 IMG_CODEC_PSD ))
650 {
651 error_message = llformat("Problem with file %s:\n\n%s\n",
652 src_filename.c_str(), LLImage::getLastError().c_str());
653 args["FILE"] = src_filename;
654 args["ERROR"] = LLImage::getLastError();
655 upload_error(error_message, "ProblemWithFile", filename, args);
656 return;
657 }
658 }
659 else if(exten == "tif" || exten == "tiff")
660 {
661 asset_type = LLAssetType::AT_TEXTURE;
662 if (!LLViewerImageList::createUploadFile(src_filename,
663 filename,
664 IMG_CODEC_TIFF ))
665 {
666 error_message = llformat("Problem with file %s:\n\n%s\n",
667 src_filename.c_str(), LLImage::getLastError().c_str());
668 args["FILE"] = src_filename;
669 args["ERROR"] = LLImage::getLastError();
670 upload_error(error_message, "ProblemWithFile", filename, args);
671 return;
672 }
673 }
674#endif
643 else if(exten == "wav") 675 else if(exten == "wav")
644 { 676 {
645 asset_type = LLAssetType::AT_SOUND; // tag it as audio 677 asset_type = LLAssetType::AT_SOUND; // tag it as audio