plug-ins: in twain, unify 8- and 16-bit data transfer

This commit is contained in:
Ell 2020-06-04 21:56:48 +03:00
parent 093d19c87c
commit 86569b9ae3
1 changed files with 6 additions and 53 deletions

View File

@ -731,19 +731,16 @@ bitTransferCallback (pTW_IMAGEINFO imageInfo,
} }
/* /*
* oneBytePerSampleTransferCallback * directTransferCallback
* *
* The following function is called for each memory * The following function is called for each memory
* block that is transferred from the data source if * block that is transferred from the data source if
* the image type is Grayscale or RGB. This transfer * the image type is Grayscale or RGB.
* 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.
*/ */
static int static int
oneBytePerSampleTransferCallback (pTW_IMAGEINFO imageInfo, directTransferCallback (pTW_IMAGEINFO imageInfo,
pTW_IMAGEMEMXFER imageMemXfer, pTW_IMAGEMEMXFER imageMemXfer,
void *clientData) void *clientData)
{ {
int rows = imageMemXfer->Rows; int rows = imageMemXfer->Rows;
int cols = imageMemXfer->Columns; int cols = imageMemXfer->Columns;
@ -764,38 +761,6 @@ oneBytePerSampleTransferCallback (pTW_IMAGEINFO imageInfo,
return TRUE; 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 * palettedTransferCallback
* *
@ -908,19 +873,7 @@ dataTransferCallback (pTW_IMAGEINFO imageInfo,
case TWPT_GRAY: case TWPT_GRAY:
case TWPT_RGB: case TWPT_RGB:
switch (imageInfo->BitsPerPixel / imageInfo->SamplesPerPixel) return directTransferCallback (imageInfo, imageMemXfer, clientData);
{
case 8:
return oneBytePerSampleTransferCallback (imageInfo, imageMemXfer,
clientData);
case 16:
return twoBytesPerSampleTransferCallback (imageInfo, imageMemXfer,
clientData);
default:
return FALSE;
}
default: default:
return FALSE; return FALSE;