Author: rmottola
Date: Thu Apr 21 09:48:26 2016
New Revision: 39687

URL: http://svn.gna.org/viewcvs/gnustep?rev=39687&view=rev
Log:
Generate thumbnail and preview only from the first available Bitmap 
representation: this means for multipage tiffs that the first page is used. 
Works around unidentified issues in certain setups where images failed to 
display. A better solution might be needed in the future in GUI itself

Modified:
    apps/gworkspace/trunk/ChangeLog
    
apps/gworkspace/trunk/GWorkspace/Thumbnailer/ImageThumbnailer/ImageThumbnailer.m
    apps/gworkspace/trunk/Inspector/ContentViewers/ImageViewer/resizer/Resizer.m

Modified: apps/gworkspace/trunk/ChangeLog
URL: 
http://svn.gna.org/viewcvs/gnustep/apps/gworkspace/trunk/ChangeLog?rev=39687&r1=39686&r2=39687&view=diff
==============================================================================
--- apps/gworkspace/trunk/ChangeLog     (original)
+++ apps/gworkspace/trunk/ChangeLog     Thu Apr 21 09:48:26 2016
@@ -1,3 +1,9 @@
+2016-04-21 Riccardo Mottola <[email protected]>
+
+       * GWorkspace/Thumbnailer/ImageThumbnailer/ImageThumbnailer.m
+       * Inspector/ContentViewers/ImageViewer/resizer/Resizer.m
+       Generate thumbnail and preview only from the first available Bitmap 
representation: this means for multipage tiffs that the first page is used. 
Works around unidentified issues in certain setups where images failed to 
display. A better solution might be needed in the future in GUI itself.
+
 2016-04-13 Riccardo Mottola <[email protected]>
 
        * FSNode/FSNodeRepIcons.m

Modified: 
apps/gworkspace/trunk/GWorkspace/Thumbnailer/ImageThumbnailer/ImageThumbnailer.m
URL: 
http://svn.gna.org/viewcvs/gnustep/apps/gworkspace/trunk/GWorkspace/Thumbnailer/ImageThumbnailer/ImageThumbnailer.m?rev=39687&r1=39686&r2=39687&view=diff
==============================================================================
--- 
apps/gworkspace/trunk/GWorkspace/Thumbnailer/ImageThumbnailer/ImageThumbnailer.m
    (original)
+++ 
apps/gworkspace/trunk/GWorkspace/Thumbnailer/ImageThumbnailer/ImageThumbnailer.m
    Thu Apr 21 09:48:26 2016
@@ -50,20 +50,37 @@
 
   if (image && [image isValid])
     {
-      NSData *tiffData = [image TIFFRepresentation];
-      NSBitmapImageRep *srcRep = [NSBitmapImageRep imageRepWithData: tiffData];
-      NSInteger srcSpp = [srcRep samplesPerPixel];
-      NSInteger bitsPerPixel = [srcRep bitsPerPixel];
+      NSData *tiffData;
+      NSEnumerator *repEnum;
+      NSBitmapImageRep *srcRep;
+      NSInteger srcSpp;
+      NSInteger bitsPerPixel;
+      NSImageRep *imgRep;
+ 
+      repEnum = [[image representations] objectEnumerator];
+      srcRep = nil;
+      imgRep = nil;
+      while (srcRep == nil && (imgRep = [repEnum nextObject]))
+        {
+          if ([imgRep isKindOfClass:[NSBitmapImageRep class]])
+            srcRep = (NSBitmapImageRep *)imgRep;
+        }
+      if (nil == srcRep)
+        return nil;
       
+      srcSpp = [srcRep samplesPerPixel];
+      bitsPerPixel = [srcRep bitsPerPixel];
       if (((srcSpp == 3) && (bitsPerPixel == 24)) 
         || ((srcSpp == 4) && (bitsPerPixel == 32))
         || ((srcSpp == 1) && (bitsPerPixel == 8))
-        || ((srcSpp == 2) && (bitsPerPixel == 16))) {
+        || ((srcSpp == 2) && (bitsPerPixel == 16)))
+        {
     
       if (([srcRep pixelsWide] <= TMBMAX) && ([srcRep pixelsHigh]<= TMBMAX) 
                               && ([srcRep pixelsWide] >= (TMBMAX - RESZLIM)) 
                                       && ([srcRep pixelsHigh] >= (TMBMAX - 
RESZLIM)))
         {
+          tiffData = [srcRep TIFFRepresentation];
           RETAIN (tiffData);
           RELEASE (image);
           RELEASE (arp);
@@ -92,8 +109,8 @@
           dstsizeW = (NSInteger)floor([srcRep pixelsWide] / fact + 0.5);
           dstsizeH = (NSInteger)floor([srcRep pixelsHigh] / fact + 0.5);
  
-          xratio = [srcRep pixelsWide] / (float)dstsizeW;
-          yratio = [srcRep pixelsHigh] / (float)dstsizeH;
+          xratio = (float)[srcRep pixelsWide] / (float)dstsizeW;
+          yratio = (float)[srcRep pixelsHigh] / (float)dstsizeH;
           
           destSamplesPerPixel = [srcRep samplesPerPixel];
           dstRep = [[NSBitmapImageRep alloc]
@@ -145,71 +162,6 @@
   return nil;
 }
 
-/*
-- (NSData *)makeThumbnailForPath:(NSString *)path
-{
-  CREATE_AUTORELEASE_POOL(arp);
-  NSImage *image = [[NSImage alloc] initWithContentsOfFile: path];
-
-  if (image && [image isValid]) {
-    NSSize size = [image size];
-    NSRect srcr = NSMakeRect(0, 0, size.width, size.height);
-         NSRect dstr = NSZeroRect;  
-    NSImageRep *rep = [image bestRepresentationForDevice: nil];
-    NSImage *newimage = nil;
-    NSBitmapImageRep *newBitmapImageRep = nil;
-    NSData *data = nil;
-
-    if ((size.width <= TMBMAX) && (size.height <= TMBMAX) 
-                            && (size.width >= (TMBMAX - RESZLIM)) 
-                                    && (size.height >= (TMBMAX - RESZLIM))) {
-           if ([rep isKindOfClass: [NSBitmapImageRep class]]) {
-        data = [(NSBitmapImageRep *)rep TIFFRepresentation];
-        if (data) {
-          RELEASE (image);
-          RETAIN (data);
-          RELEASE (arp);
-          
-          return [data autorelease];
-        }
-      }
-    }
-
-    if (size.width >= size.height) {
-      dstr.size.width = TMBMAX;
-      dstr.size.height = TMBMAX * size.height / size.width;
-    } else {
-      dstr.size.height = TMBMAX;
-      dstr.size.width = TMBMAX * size.width / size.height;
-    }  
-          
-    newimage = [[NSImage alloc] initWithSize: dstr.size];
-    [newimage lockFocus];
-
-    [image drawInRect: dstr 
-             fromRect: srcr 
-            operation: NSCompositeSourceOver 
-             fraction: 1.0];
-
-    newBitmapImageRep = [[NSBitmapImageRep alloc] initWithFocusedViewRect: 
dstr];
-    [newimage unlockFocus];
-
-    data = [newBitmapImageRep TIFFRepresentation];
-    RETAIN (data);
-    
-    RELEASE (image);
-    RELEASE (newimage);
-    RELEASE (newBitmapImageRep);
-    RELEASE (arp);
-    
-    return [data autorelease];
-  }
-
-  RELEASE (arp);
-    
-  return nil;
-}
-*/
 
 - (NSString *)fileNameExtension
 {

Modified: 
apps/gworkspace/trunk/Inspector/ContentViewers/ImageViewer/resizer/Resizer.m
URL: 
http://svn.gna.org/viewcvs/gnustep/apps/gworkspace/trunk/Inspector/ContentViewers/ImageViewer/resizer/Resizer.m?rev=39687&r1=39686&r2=39687&view=diff
==============================================================================
--- 
apps/gworkspace/trunk/Inspector/ContentViewers/ImageViewer/resizer/Resizer.m    
    (original)
+++ 
apps/gworkspace/trunk/Inspector/ContentViewers/ImageViewer/resizer/Resizer.m    
    Thu Apr 21 09:48:26 2016
@@ -1,6 +1,6 @@
 /* Resizer.m
  *  
- * Copyright (C) 2005 Free Software Foundation, Inc.
+ * Copyright (C) 2005-2016 Free Software Foundation, Inc.
  *
  * Author: Enrico Sersale <[email protected]>
  * Date: January 2005
@@ -121,36 +121,56 @@
   NSMutableDictionary *info = [NSMutableDictionary dictionary];
   NSImage *srcImage = [[NSImage alloc] initWithContentsOfFile: path];
 
-  if (srcImage && [srcImage isValid]) {
-    NSData *srcData = [srcImage TIFFRepresentation];
-    NSBitmapImageRep *srcRep = [NSBitmapImageRep imageRepWithData: srcData];
-    NSInteger srcSpp = [srcRep samplesPerPixel];
-    int bitsPerPixel = [srcRep bitsPerPixel];
-    NSInteger srcsizeW = [srcRep pixelsWide];
-    NSInteger srcsizeH = [srcRep pixelsHigh];
-    NSInteger srcBytesPerPixel = [srcRep bitsPerPixel] / 8;
-    NSInteger srcBytesPerRow = [srcRep bytesPerRow];
-
-    [info setObject: [NSNumber numberWithFloat: (float)srcsizeW] forKey: 
@"width"];
-    [info setObject: [NSNumber numberWithFloat: (float)srcsizeH] forKey: 
@"height"];
-
-    if (((imsize.width < srcsizeW) || (imsize.height < srcsizeH))
-                                && (((srcSpp == 3) && (bitsPerPixel == 24)) 
-                                    || ((srcSpp == 4) && (bitsPerPixel == 32))
-                                    || ((srcSpp == 1) && (bitsPerPixel == 8))
-                                    || ((srcSpp == 2) && (bitsPerPixel == 
16)))) {
-      NSInteger destSamplesPerPixel = srcSpp;
-      NSInteger destBytesPerRow;
-      NSInteger destBytesPerPixel;
-      NSInteger dstsizeW, dstsizeH;
-      float xratio, yratio;
-      NSBitmapImageRep *dstRep;
-      NSData *tiffData;
-      unsigned char *srcData;
-      unsigned char *destData;
-      unsigned x, y;
-      unsigned i;
-      
+  if (srcImage && [srcImage isValid])
+    {
+      NSData *srcData = [srcImage TIFFRepresentation];
+      NSBitmapImageRep *srcRep;
+      NSInteger srcSpp;
+      NSInteger bitsPerPixel;
+      NSInteger srcsizeW;
+      NSInteger srcsizeH;
+      NSInteger srcBytesPerPixel;
+      NSInteger srcBytesPerRow;
+      NSEnumerator *repEnum;
+      NSImageRep *imgRep;
+    
+      repEnum = [[srcImage representations] objectEnumerator];
+      srcRep = nil;
+      imgRep = nil;
+      while (srcRep == nil && (imgRep = [repEnum nextObject]))
+        {
+          if ([imgRep isKindOfClass:[NSBitmapImageRep class]])
+            srcRep = (NSBitmapImageRep *)imgRep;
+        }
+      
+      srcSpp = [srcRep samplesPerPixel];
+      bitsPerPixel = [srcRep bitsPerPixel];
+      srcsizeW = [srcRep pixelsWide];
+      srcsizeH = [srcRep pixelsHigh];
+      srcBytesPerPixel = [srcRep bitsPerPixel] / 8;
+      srcBytesPerRow = [srcRep bytesPerRow];
+      
+      [info setObject: [NSNumber numberWithFloat: (float)srcsizeW] forKey: 
@"width"];
+      [info setObject: [NSNumber numberWithFloat: (float)srcsizeH] forKey: 
@"height"];
+      
+      if (((imsize.width < srcsizeW) || (imsize.height < srcsizeH))
+          && (((srcSpp == 3) && (bitsPerPixel == 24)) 
+              || ((srcSpp == 4) && (bitsPerPixel == 32))
+              || ((srcSpp == 1) && (bitsPerPixel == 8))
+              || ((srcSpp == 2) && (bitsPerPixel == 16))))
+        {
+          NSInteger destSamplesPerPixel = srcSpp;
+          NSInteger destBytesPerRow;
+          NSInteger destBytesPerPixel;
+          NSInteger dstsizeW, dstsizeH;
+          float xratio, yratio;
+          NSBitmapImageRep *dstRep;
+          NSData *tiffData;
+          unsigned char *srcData;
+          unsigned char *destData;
+          unsigned x, y;
+          unsigned i;
+          
       if ((imsize.width / srcsizeW) <= (imsize.height / srcsizeH)) {
         dstsizeW = floor(imsize.width + 0.5);
         dstsizeH = floor(dstsizeW * srcsizeH / srcsizeW + 0.5);


_______________________________________________
Gnustep-cvs mailing list
[email protected]
https://mail.gna.org/listinfo/gnustep-cvs

Reply via email to