[gimp/gimp-2-10] plug-ins: in twain, unify 8- and 16-bit data transfer



commit d4ce6c5453b12f848ea6b8c5bb11ace6b36b02f9
Author: Ell <ell_se yahoo com>
Date:   Thu Jun 4 21:56:48 2020 +0300

    plug-ins: in twain, unify 8- and 16-bit data transfer
    
    (cherry picked from commit 86569b9ae30b5407e43ed2e3b074906d9576c816)

 plug-ins/twain/twain.c | 59 +++++---------------------------------------------
 1 file changed, 6 insertions(+), 53 deletions(-)
---
diff --git a/plug-ins/twain/twain.c b/plug-ins/twain/twain.c
index 5389e1f0f0..dafb215d51 100644
--- a/plug-ins/twain/twain.c
+++ b/plug-ins/twain/twain.c
@@ -732,19 +732,16 @@ bitTransferCallback (pTW_IMAGEINFO     imageInfo,
 }
 
 /*
- * oneBytePerSampleTransferCallback
+ * directTransferCallback
  *
  * The following function is called for each memory
  * block that is transferred from the data source if
- * the image type is Grayscale or RGB.  This transfer
- * mode is quicker than the modes that require translation
- * from a greater number of bits per sample down to the
- * 8 bits per sample understood by GIMP.
+ * the image type is Grayscale or RGB.
  */
 static int
-oneBytePerSampleTransferCallback (pTW_IMAGEINFO     imageInfo,
-                                  pTW_IMAGEMEMXFER  imageMemXfer,
-                                  void             *clientData)
+directTransferCallback (pTW_IMAGEINFO     imageInfo,
+                        pTW_IMAGEMEMXFER  imageMemXfer,
+                        void             *clientData)
 {
   int rows = imageMemXfer->Rows;
   int cols = imageMemXfer->Columns;
@@ -765,38 +762,6 @@ oneBytePerSampleTransferCallback (pTW_IMAGEINFO     imageInfo,
   return TRUE;
 }
 
-/*
- * twoBytesPerSampleTransferCallback
- *
- * The following function is called for each memory
- * block that is transferred from the data source if
- * the image type is Grayscale or RGB.
- */
-static int
-twoBytesPerSampleTransferCallback (pTW_IMAGEINFO     imageInfo,
-                                   pTW_IMAGEMEMXFER  imageMemXfer,
-                                   void             *clientData)
-{
-  int rows = imageMemXfer->Rows;
-  int cols = imageMemXfer->Columns;
-
-  pClientDataStruct theClientData = (pClientDataStruct) clientData;
-
-  /* Send the complete chunk */
-  gegl_buffer_set (theClientData->buffer,
-                   GEGL_RECTANGLE (imageMemXfer->XOffset, imageMemXfer->YOffset,
-                                   cols, rows), 0,
-                   theClientData->format, imageMemXfer->Memory.TheMem,
-                   GEGL_AUTO_ROWSTRIDE);
-
-  /* Update the user on our progress */
-  theClientData->completedPixels += (cols * rows);
-  gimp_progress_update ((double) theClientData->completedPixels /
-                        (double) theClientData->totalPixels);
-
-  return TRUE;
-}
-
 /*
  * palettedTransferCallback
  *
@@ -909,19 +874,7 @@ dataTransferCallback (pTW_IMAGEINFO     imageInfo,
 
     case TWPT_GRAY:
     case TWPT_RGB:
-      switch (imageInfo->BitsPerPixel / imageInfo->SamplesPerPixel)
-        {
-        case 8:
-          return oneBytePerSampleTransferCallback (imageInfo, imageMemXfer,
-                                                   clientData);
-
-        case 16:
-          return twoBytesPerSampleTransferCallback (imageInfo, imageMemXfer,
-                                                    clientData);
-
-        default:
-          return FALSE;
-        }
+      return directTransferCallback (imageInfo, imageMemXfer, clientData);
 
     default:
       return FALSE;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]