mirror of https://github.com/GNOME/gimp.git
Merge from stable branch :
2004-05-09 Hans Breuer <hans@breuer.org> Merge from stable branch : * plug-ins/common/winclipboard.c : support gray images; fixes bug #141382 * plug-ins/common/winprint.c : dito; fixes bug #141145
This commit is contained in:
parent
ebd4d61eff
commit
b03e10fdb4
|
@ -1,3 +1,12 @@
|
|||
2004-05-09 Hans Breuer <hans@breuer.org>
|
||||
|
||||
Merge from stable branch :
|
||||
|
||||
* plug-ins/common/winclipboard.c : support gray images;
|
||||
fixes bug #141382
|
||||
|
||||
* plug-ins/common/winprint.c : dito; fixes bug #141145
|
||||
|
||||
2004-05-09 Maurits Rijk <m.rijk@chello.nl>
|
||||
|
||||
* plug-ins/common/aa.c
|
||||
|
|
|
@ -107,7 +107,7 @@ query ()
|
|||
"Hans Breuer",
|
||||
"1999",
|
||||
N_("Copy to Clipboard"),
|
||||
"INDEXED*, RGB*",
|
||||
"INDEXED*, RGB*, GRAY*",
|
||||
GIMP_PLUGIN,
|
||||
G_N_ELEMENTS (copy_args), 0,
|
||||
copy_args, NULL);
|
||||
|
@ -119,7 +119,7 @@ query ()
|
|||
"Hans Breuer",
|
||||
"1999",
|
||||
N_("Paste from Clipboard"),
|
||||
"INDEXED*, RGB*",
|
||||
"INDEXED*, RGB*, GRAY*",
|
||||
GIMP_PLUGIN,
|
||||
G_N_ELEMENTS (copy_args), 0,
|
||||
copy_args, NULL);
|
||||
|
@ -219,7 +219,7 @@ CB_CopyImage (gboolean interactive,
|
|||
gimp_pixel_rgn_init (&pixel_rgn, drawable, 0, 0, drawable->width, drawable->height, FALSE, FALSE);
|
||||
|
||||
/* allocate room for DIB */
|
||||
if (GIMP_INDEXED_IMAGE == drawable_type)
|
||||
if (GIMP_INDEXED_IMAGE == drawable_type || GIMP_GRAY_IMAGE == drawable_type)
|
||||
{
|
||||
nSizeLine = ((drawable->width-1)/4+1)*4;
|
||||
nSizeDIB = sizeof(RGBQUAD) * 256 /* always full color map size */
|
||||
|
@ -253,13 +253,15 @@ CB_CopyImage (gboolean interactive,
|
|||
pInfo->biWidth = drawable->width;
|
||||
pInfo->biHeight = drawable->height;
|
||||
pInfo->biPlanes = 1;
|
||||
pInfo->biBitCount = (GIMP_INDEXED_IMAGE == drawable_type ? 8 : 24);
|
||||
pInfo->biBitCount =
|
||||
(GIMP_INDEXED_IMAGE == drawable_type || GIMP_GRAY_IMAGE == drawable_type ? 8 : 24);
|
||||
pInfo->biCompression = BI_RGB; /* none */
|
||||
pInfo->biSizeImage = 0; /* not calculated/needed */
|
||||
pInfo->biXPelsPerMeter =
|
||||
pInfo->biYPelsPerMeter = 0;
|
||||
/* color map size */
|
||||
pInfo->biClrUsed = (GIMP_INDEXED_IMAGE == drawable_type ? 256 : 0);
|
||||
pInfo->biClrUsed =
|
||||
(GIMP_INDEXED_IMAGE == drawable_type || GIMP_GRAY_IMAGE == drawable_type ? 256 : 0);
|
||||
pInfo->biClrImportant = 0; /* all */
|
||||
|
||||
GlobalUnlock (hDIB);
|
||||
|
@ -270,7 +272,7 @@ CB_CopyImage (gboolean interactive,
|
|||
}
|
||||
|
||||
/* fill color map */
|
||||
if (bRet && (GIMP_INDEXED_IMAGE == drawable_type))
|
||||
if (bRet && (GIMP_INDEXED_IMAGE == drawable_type || GIMP_GRAY_IMAGE == drawable_type))
|
||||
{
|
||||
char *pBmp;
|
||||
|
||||
|
@ -280,12 +282,13 @@ CB_CopyImage (gboolean interactive,
|
|||
{
|
||||
RGBQUAD *pPal;
|
||||
int nColors;
|
||||
unsigned char *cmap;
|
||||
unsigned char *cmap = NULL;
|
||||
pPal = (RGBQUAD*)(pBmp + sizeof(BITMAPINFOHEADER));
|
||||
nSizePal = sizeof(RGBQUAD) * 256;
|
||||
|
||||
/* get the gimp colormap */
|
||||
cmap = gimp_image_get_cmap (image_ID, &nColors);
|
||||
if (GIMP_GRAY_IMAGE != drawable_type)
|
||||
cmap = gimp_image_get_cmap (image_ID, &nColors);
|
||||
|
||||
if (cmap)
|
||||
{
|
||||
|
@ -301,13 +304,27 @@ CB_CopyImage (gboolean interactive,
|
|||
g_free(cmap);
|
||||
bRet = TRUE;
|
||||
} /* (cmap) */
|
||||
else if (GIMP_GRAY_IMAGE == drawable_type)
|
||||
{
|
||||
/* fill with identity palette */
|
||||
int i;
|
||||
for (i = 0; (i < 256) && (i < nColors); i++)
|
||||
{
|
||||
pPal[i].rgbReserved = 0; /* is this alpha? */
|
||||
pPal[i].rgbRed = i;
|
||||
pPal[i].rgbGreen = i;
|
||||
pPal[i].rgbBlue = i;
|
||||
}
|
||||
|
||||
bRet = TRUE;
|
||||
}
|
||||
else
|
||||
g_message ("Can't get color map");
|
||||
GlobalUnlock (hDIB);
|
||||
} /* (pBmp) */
|
||||
else
|
||||
g_message ("Failed to lock DIB Palette");
|
||||
} /* indexed */
|
||||
} /* indexed or grayscale */
|
||||
|
||||
/* following the slow part ... */
|
||||
if (interactive)
|
||||
|
@ -333,7 +350,7 @@ CB_CopyImage (gboolean interactive,
|
|||
|
||||
pLine = g_new (guchar, drawable->width * drawable->bpp);
|
||||
|
||||
if (GIMP_INDEXED_IMAGE == drawable_type)
|
||||
if (GIMP_INDEXED_IMAGE == drawable_type || GIMP_GRAY_IMAGE == drawable_type)
|
||||
{
|
||||
int x, y;
|
||||
for (y = 0; y < drawable->height; y++)
|
||||
|
|
|
@ -107,6 +107,44 @@ indexed_to_bgr(guchar *indexed,
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gray_to_bgr(guchar *indexed,
|
||||
guchar *bgrout,
|
||||
int width,
|
||||
int bpp,
|
||||
guchar *cmap,
|
||||
int ncolours)
|
||||
{
|
||||
if (bpp == 1)
|
||||
{
|
||||
/* No alpha in image. */
|
||||
|
||||
while (width > 0)
|
||||
{
|
||||
bgrout[2] =
|
||||
bgrout[1] =
|
||||
bgrout[0] = *indexed; /* identity */
|
||||
bgrout += 3;
|
||||
indexed ++;
|
||||
width --;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Indexed alpha image. */
|
||||
|
||||
while (width > 0)
|
||||
{
|
||||
bgrout[2] =
|
||||
bgrout[1] =
|
||||
bgrout[0] = indexed[0] * indexed[1] / 255 + 255 - indexed[1];
|
||||
bgrout += 3;
|
||||
indexed += bpp;
|
||||
width --;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
rgb_to_bgr(guchar *rgbin,
|
||||
guchar *bgrout,
|
||||
|
@ -223,7 +261,7 @@ run (const gchar *name,
|
|||
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
|
||||
GimpParam *values;
|
||||
GimpPixelRgn rgn;
|
||||
guchar *cmap; /* Colourmap (indexed images only) */
|
||||
guchar *cmap = NULL; /* Colourmap (indexed images only) */
|
||||
DEVMODE *dmp;
|
||||
int ncolours;
|
||||
int width, height;
|
||||
|
@ -357,11 +395,10 @@ run (const gchar *name,
|
|||
|
||||
if (gimp_image_base_type(param[1].data.d_image) == GIMP_INDEXED)
|
||||
cmap = gimp_image_get_cmap(param[1].data.d_image, &ncolours);
|
||||
else if (gimp_image_base_type(param[1].data.d_image) == GIMP_GRAY)
|
||||
ncolours = 256;
|
||||
else
|
||||
{
|
||||
cmap = NULL;
|
||||
ncolours = 0;
|
||||
}
|
||||
ncolours = 0;
|
||||
|
||||
/* Start print job. */
|
||||
docInfo.cbSize = sizeof (DOCINFO);
|
||||
|
@ -432,6 +469,8 @@ run (const gchar *name,
|
|||
|
||||
if (cmap != NULL)
|
||||
pixel_transfer = indexed_to_bgr;
|
||||
else if (ncolours > 0)
|
||||
pixel_transfer = gray_to_bgr;
|
||||
else
|
||||
pixel_transfer = rgb_to_bgr;
|
||||
|
||||
|
|
Loading…
Reference in New Issue