< prev index next >

src/java.desktop/share/native/liblcms/cmsalpha.c

Print this page
@@ -429,11 +429,11 @@
  
  
  
  // This function computes the distance from each component to the next one in bytes.
  static
- void ComputeIncrementsForChunky(cmsUInt32Number Format,
+ cmsBool ComputeIncrementsForChunky(cmsUInt32Number Format,
                                  cmsUInt32Number ComponentStartingOrder[],
                                  cmsUInt32Number ComponentPointerIncrements[])
  {
         cmsUInt32Number channels[cmsMAXCHANNELS];
         cmsUInt32Number extra = T_EXTRA(Format);

@@ -443,11 +443,11 @@
         cmsUInt32Number channelSize = trueBytesSize(Format);
         cmsUInt32Number pixelSize = channelSize * total_chans;
  
         // Sanity check
         if (total_chans <= 0 || total_chans >= cmsMAXCHANNELS)
-            return;
+            return FALSE;
  
          memset(channels, 0, sizeof(channels));
  
         // Separation is independent of starting point and only depends on channel size
         for (i = 0; i < extra; i++)

@@ -480,17 +480,19 @@
                       channels[i] *= channelSize;
                }
  
         for (i = 0; i < extra; i++)
                ComponentStartingOrder[i] = channels[i + nchannels];
+ 
+        return TRUE;
  }
  
  
  
  //  On planar configurations, the distance is the stride added to any non-negative
  static
- void ComputeIncrementsForPlanar(cmsUInt32Number Format,
+ cmsBool ComputeIncrementsForPlanar(cmsUInt32Number Format,
                                  cmsUInt32Number BytesPerPlane,
                                  cmsUInt32Number ComponentStartingOrder[],
                                  cmsUInt32Number ComponentPointerIncrements[])
  {
         cmsUInt32Number channels[cmsMAXCHANNELS];

@@ -500,11 +502,11 @@
         cmsUInt32Number i;
         cmsUInt32Number channelSize = trueBytesSize(Format);
  
         // Sanity check
         if (total_chans <= 0 || total_chans >= cmsMAXCHANNELS)
-            return;
+            return FALSE;
  
         memset(channels, 0, sizeof(channels));
  
         // Separation is independent of starting point and only depends on channel size
         for (i = 0; i < extra; i++)

@@ -536,33 +538,33 @@
                channels[i] *= BytesPerPlane;
         }
  
         for (i = 0; i < extra; i++)
                ComponentStartingOrder[i] = channels[i + nchannels];
+ 
+        return TRUE;
  }
  
  
  
  // Dispatcher por chunky and planar RGB
  static
- void  ComputeComponentIncrements(cmsUInt32Number Format,
+ cmsBool ComputeComponentIncrements(cmsUInt32Number Format,
                                   cmsUInt32Number BytesPerPlane,
                                   cmsUInt32Number ComponentStartingOrder[],
                                   cmsUInt32Number ComponentPointerIncrements[])
  {
         if (T_PLANAR(Format)) {
  
-               ComputeIncrementsForPlanar(Format,  BytesPerPlane, ComponentStartingOrder, ComponentPointerIncrements);
+               return ComputeIncrementsForPlanar(Format,  BytesPerPlane, ComponentStartingOrder, ComponentPointerIncrements);
         }
         else {
-               ComputeIncrementsForChunky(Format,  ComponentStartingOrder, ComponentPointerIncrements);
+               return ComputeIncrementsForChunky(Format,  ComponentStartingOrder, ComponentPointerIncrements);
         }
  
  }
  
- 
- 
  // Handles extra channels copying alpha if requested by the flags
  void _cmsHandleExtraChannels(_cmsTRANSFORM* p, const void* in,
                                                 void* out,
                                                 cmsUInt32Number PixelsPerLine,
                                                 cmsUInt32Number LineCount,

@@ -593,12 +595,14 @@
      // Anything to do?
      if (nExtra == 0)
          return;
  
      // Compute the increments
-     ComputeComponentIncrements(p->InputFormat, Stride->BytesPerPlaneIn, SourceStartingOrder, SourceIncrements);
-     ComputeComponentIncrements(p->OutputFormat, Stride->BytesPerPlaneOut, DestStartingOrder, DestIncrements);
+     if (!ComputeComponentIncrements(p->InputFormat, Stride->BytesPerPlaneIn, SourceStartingOrder, SourceIncrements))
+         return;
+     if (!ComputeComponentIncrements(p->OutputFormat, Stride->BytesPerPlaneOut, DestStartingOrder, DestIncrements))
+         return;
  
      // Check for conversions 8, 16, half, float, dbl
      copyValueFn = _cmsGetFormatterAlpha(p->ContextID, p->InputFormat, p->OutputFormat);
      if (copyValueFn == NULL)
          return;
< prev index next >