home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 2002 April / pcpro0402.iso / essentials / graphics / Gimp / gimp-src-20001226.exe / src / gimp / plug-ins / common / winclipboard.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-09-29  |  16.7 KB  |  652 lines

  1. /*
  2.  * WinClipboard Win32 Windoze Copy&Paste Plug-in
  3.  * Copyright (C) 1999 Hans Breuer
  4.  * Hans Breuer, Hans@Breuer.org
  5.  * 08/07/99
  6.  *
  7.  * This program is free software; you can redistribute it and/or modify
  8.  * it under the terms of the GNU General Public License as published by
  9.  * the Free Software Foundation; either version 2 of the License, or
  10.  * (at your option) any later version.
  11.  *
  12.  * This program is distributed in the hope that it will be useful,
  13.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15.  * GNU General Public License for more details.
  16.  *
  17.  * You should have received a copy of the GNU General Public License
  18.  * along with this program; if not, write to the Free Software
  19.  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  20.  *
  21.  * Based on (at least) the following plug-ins:
  22.  *  Header
  23.  *  WinSnap
  24.  *
  25.  * Any suggestions, bug-reports or patches are welcome.
  26.  */
  27.  
  28. #include "config.h"
  29.  
  30. #include <windows.h>
  31. #include <stdlib.h>
  32.  
  33. #include <libgimp/gimp.h>
  34.  
  35. #include "libgimp/stdplugins-intl.h"
  36.  
  37.  
  38. /* History:
  39.  *  
  40.  *   08/07/99 Implementation and release.
  41.  *     08/10/99 Big speed increase by using gimp_tile_cache_size()
  42.  *              Thanks to Kevin Turner's documentation at:
  43.  *              http://www.poboxes.com/kevint/gimp/doc/plugin-doc-2.1.html
  44.  *
  45.  * TODO (maybe):
  46.  *
  47.  *   - Support for 4,2,1 bit bitmaps
  48.  *   - Unsupported formats could be delegated to GIMP Loader (e.g. wmf)
  49.  *   - ...
  50.  */
  51.  
  52. /* How many steps the progress control should do
  53.  */
  54. #define PROGRESS_STEPS 25
  55. #define StepProgress(one,all) \
  56.     (0 == (one % ((all / PROGRESS_STEPS)+1)))
  57.  
  58. /* FIXME: I'll use -1 as IMAGE_NONE. Is it correct ???
  59.  */
  60. #define IMAGE_NONE -1
  61.  
  62. /* Declare some local functions.
  63.  */
  64. static void   query      (void);
  65. static void   run        (gchar   *name,
  66.                           gint     nparams,
  67.                           GimpParam  *param,
  68.                           gint    *nreturn_vals,
  69.                           GimpParam **return_vals);
  70.  
  71. /* Plugin function prototypes
  72.  */
  73. static int CB_CopyImage (gboolean interactive,
  74.                          gint32   image_ID,
  75.                          gint32   drawable_ID);
  76.  
  77. static int CB_PasteImage (gboolean   interactive,
  78.                           gint32  image_ID,
  79.                           gint32  drawable_ID);
  80.  
  81.  
  82. GimpPlugInInfo PLUG_IN_INFO =
  83. {
  84.   NULL,  /* init_proc  */
  85.   NULL,  /* quit_proc  */
  86.   query, /* query_proc */
  87.   run,   /* run_proc   */
  88. };
  89.  
  90.  
  91. MAIN ()
  92.  
  93. static void
  94. query ()
  95. {
  96.   static GimpParamDef copy_args[] =
  97.   {
  98.     { GIMP_PDB_INT32, "run_mode", "Interactive, non-interactive" },
  99.     { GIMP_PDB_IMAGE, "image", "Input image" },
  100.     { GIMP_PDB_DRAWABLE, "drawable", "Drawable to save" }
  101.   };
  102.   static gint ncopy_args = sizeof (copy_args) / sizeof (copy_args[0]);
  103.  
  104.   gimp_install_procedure ("plug_in_clipboard_copy",
  105.                           "copy image to clipboard",
  106.                           "Copies the active drawable to the clipboard.",
  107.                           "Hans Breuer",
  108.                           "Hans Breuer",
  109.                           "1999",
  110.                           N_("<Image>/Edit/Copy to Clipboard"),
  111.                           "INDEXED*, RGB*",
  112.                           GIMP_PLUGIN,
  113.                           ncopy_args, 0,
  114.                           copy_args, NULL);
  115.  
  116.   gimp_install_procedure ("plug_in_clipboard_paste",
  117.                           "paste image from clipboard",
  118.                           "Paste image from clipboard into active image.",
  119.                           "Hans Breuer",
  120.                           "Hans Breuer",
  121.                           "1999",
  122.                           N_("<Image>/Edit/Paste from Clipboard"),
  123.                           "INDEXED*, RGB*",
  124.                           GIMP_PLUGIN,
  125.                           ncopy_args, 0,
  126.                           copy_args, NULL);
  127.  
  128.   gimp_install_procedure ("extension_clipboard_paste",
  129.                           "Get image from clipboard",
  130.                           "Get an image from the Windows clipboard, creating a new image",
  131.                           "Hans Breuer",
  132.                           "Hans Breuer",
  133.                           "1999",
  134.                           N_("<Toolbox>/File/Acquire/From Clipboard"),
  135.                           "",
  136.                           GIMP_EXTENSION,
  137.                           ncopy_args, 0,
  138.                           copy_args, NULL);
  139.  
  140. }
  141.  
  142. static void
  143. run (gchar   *name,
  144.      gint     nparams,
  145.      GimpParam  *param,
  146.      gint    *nreturn_vals,
  147.      GimpParam **return_vals)
  148. {
  149.   static GimpParam values[2];
  150.   GimpRunModeType run_mode;
  151.  
  152.   run_mode = param[0].data.d_int32;
  153.  
  154.   *nreturn_vals = 1;
  155.   *return_vals = values;
  156.   values[0].type = GIMP_PDB_STATUS;
  157.   values[0].data.d_status = GIMP_PDB_CALLING_ERROR;
  158.  
  159.   INIT_I18N();
  160.  
  161.   if (strcmp (name, "plug_in_clipboard_copy") == 0)
  162.   {
  163.       *nreturn_vals = 1;
  164.       if (CB_CopyImage (GIMP_RUN_INTERACTIVE==run_mode,
  165.                         param[1].data.d_int32, 
  166.                         param[2].data.d_int32))
  167.         values[0].data.d_status = GIMP_PDB_SUCCESS;
  168.       else
  169.         values[0].data.d_status = GIMP_PDB_EXECUTION_ERROR;
  170.     }
  171.   else if (strcmp (name, "plug_in_clipboard_paste") == 0)
  172.     {
  173.       *nreturn_vals = 1;
  174.       if (CB_PasteImage (GIMP_RUN_INTERACTIVE==run_mode,
  175.                          param[1].data.d_int32, 
  176.                          param[2].data.d_int32))
  177.         values[0].data.d_status = GIMP_PDB_SUCCESS;
  178.       else
  179.         values[0].data.d_status = GIMP_PDB_EXECUTION_ERROR;
  180.     }
  181.   else if (strcmp (name, "extension_clipboard_paste") == 0)
  182.     {
  183.       *nreturn_vals = 1;
  184.       if (CB_PasteImage (GIMP_RUN_INTERACTIVE==run_mode,
  185.                          IMAGE_NONE,
  186.                          IMAGE_NONE))
  187.         values[0].data.d_status = GIMP_PDB_SUCCESS;
  188.       else
  189.         values[0].data.d_status = GIMP_PDB_EXECUTION_ERROR;
  190.     }
  191. }
  192.  
  193. /* Plugin Function implementation
  194.  */
  195. static int
  196. CB_CopyImage (gboolean interactive,
  197.               gint32   image_ID,
  198.               gint32   drawable_ID)
  199. {
  200.     GimpDrawable *drawable;
  201.     GimpImageType drawable_type;
  202.     GimpPixelRgn pixel_rgn;
  203.     gchar* sStatus = NULL;
  204.  
  205.     int nSizeDIB=0;
  206.     int nSizePal=0;
  207.     int nSizeLine=0; /* DIB lines are 32 bit aligned */
  208.  
  209.     HANDLE hDIB;
  210.     BOOL   bRet;
  211.  
  212.     drawable = gimp_drawable_get (drawable_ID);
  213.     drawable_type = gimp_drawable_type (drawable_ID);
  214.     gimp_pixel_rgn_init (&pixel_rgn, drawable, 0, 0, drawable->width, drawable->height, FALSE, FALSE);
  215.  
  216.     /* allocate room for DIB */
  217.     if (GIMP_INDEXED_IMAGE == drawable_type)
  218.     {
  219.       nSizeLine = ((drawable->width-1)/4+1)*4;
  220.       nSizeDIB = sizeof(RGBQUAD) * 256 /* always full color map size */
  221.                  + nSizeLine * drawable->height
  222.                  + sizeof (BITMAPINFOHEADER);
  223.     }
  224.     else
  225.     {
  226.       nSizeLine = ((drawable->width*3-1)/4+1)*4;
  227.       nSizeDIB = nSizeLine * drawable->height
  228.                  + sizeof (BITMAPINFOHEADER);
  229.     }
  230.  
  231.     hDIB = GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, nSizeDIB);
  232.     if (NULL == hDIB)
  233.     {
  234.       g_warning("Failed to allocate DIB");
  235.       bRet = FALSE;
  236.     }
  237.  
  238.     /* fill header info */
  239.     if (bRet)
  240.     {
  241.       BITMAPINFOHEADER* pInfo;
  242.  
  243.       bRet = FALSE;
  244.       pInfo = GlobalLock(hDIB);
  245.       if (pInfo)
  246.       {
  247.           pInfo->biSize   = sizeof(BITMAPINFOHEADER);
  248.           pInfo->biWidth  = drawable->width;
  249.           pInfo->biHeight = drawable->height;
  250.           pInfo->biPlanes = 1;
  251.           pInfo->biBitCount = (GIMP_INDEXED_IMAGE == drawable_type ? 8 : 24);
  252.           pInfo->biCompression = BI_RGB; /* none */
  253.           pInfo->biSizeImage = 0; /* not calculated/needed */
  254.           pInfo->biXPelsPerMeter =
  255.           pInfo->biYPelsPerMeter = 0;
  256.           /* color map size */
  257.           pInfo->biClrUsed = (GIMP_INDEXED_IMAGE == drawable_type ? 256 : 0);
  258.           pInfo->biClrImportant = 0; /* all */
  259.  
  260.           GlobalUnlock(hDIB);
  261.           bRet = TRUE;
  262.       } /* (pInfo) */
  263.       else
  264.           g_warning("Failed to lock DIB Header");
  265.     }
  266.  
  267.     /* fill color map */
  268.     if (bRet && (GIMP_INDEXED_IMAGE == drawable_type))
  269.     {
  270.       char*    pBmp;
  271.  
  272.       bRet = FALSE;
  273.       pBmp = GlobalLock(hDIB);
  274.       if (pBmp)
  275.       {
  276.           RGBQUAD* pPal;
  277.           int nColors;
  278.           unsigned char *cmap;
  279.           pPal = (RGBQUAD*)(pBmp + sizeof(BITMAPINFOHEADER));
  280.           nSizePal = sizeof(RGBQUAD) * 256;
  281.  
  282.           /* get the gimp colormap */
  283.           cmap = gimp_image_get_cmap (image_ID, &nColors);
  284.  
  285.           if (cmap)
  286.           {
  287.               int i;
  288.               for (i = 0; (i < 256) && (i < nColors); i++)
  289.               {
  290.                   pPal[i].rgbReserved = 0; /* is this alpha? */
  291.                   pPal[i].rgbRed      = cmap[3*i];
  292.                   pPal[i].rgbGreen    = cmap[3*i+1];
  293.                   pPal[i].rgbBlue     = cmap[3*i+2];
  294.               }
  295.               
  296.               g_free(cmap);
  297.               bRet = TRUE;
  298.           } /* (cmap) */
  299.           else
  300.               g_warning("Can't get color map");
  301.           GlobalUnlock(hDIB);
  302.       } /* (pBmp) */
  303.       else
  304.           g_warning("Failed to lock DIB Palette");
  305.     } /* indexed */
  306.  
  307.     /* following the slow part ... */
  308.     if (interactive)
  309.       gimp_progress_init ( _("Copying ..."));
  310.  
  311.     /* speed it up with: */
  312.     gimp_tile_cache_size(  drawable->width * gimp_tile_height() 
  313.                             * drawable->bpp );
  314.  
  315.     /* copy data to DIB */
  316.     if (bRet)
  317.     {
  318.       unsigned char* pData;
  319.  
  320.       bRet = FALSE;
  321.       pData = GlobalLock(hDIB);
  322.  
  323.       if (pData)
  324.       {
  325.           unsigned char* pLine;
  326.  
  327.           /* calculate real offset */
  328.           pData += (sizeof(BITMAPINFOHEADER) + nSizePal);
  329.  
  330.           pLine = g_new (guchar, drawable->width * drawable->bpp);
  331.  
  332.           if (pLine)
  333.           {
  334.               if (GIMP_INDEXED_IMAGE == drawable_type)
  335.               {
  336.                   int x, y;
  337.                   for (y = 0; y < drawable->height; y++)
  338.                   {
  339.                       if ((interactive) && (StepProgress(y,drawable->height)))
  340.                           gimp_progress_update((double)y / drawable->height);
  341.  
  342.                       gimp_pixel_rgn_get_row (&pixel_rgn, pLine, 0, 
  343.                                               drawable->height-y-1, /* invert it */
  344.                                               drawable->width);
  345.                       for (x = 0; x < drawable->width; x++)
  346.                           pData[x+y*nSizeLine] = pLine[x*drawable->bpp];
  347.                   }
  348.               }
  349.               else
  350.               {
  351.                   int x, y;
  352.                   for (y = 0; y < drawable->height; y++)
  353.                   {
  354.                       if ((interactive) && (StepProgress(y,drawable->height)))
  355.                           gimp_progress_update((double)y / drawable->height);
  356.  
  357.                       gimp_pixel_rgn_get_row (&pixel_rgn, pLine, 0, 
  358.                                               drawable->height-y-1, /* invert it */
  359.                                               drawable->width);
  360.                       for (x = 0; x < drawable->width; x++)
  361.                       {
  362.                           /* RGBQUAD: blue, green, red, reserved */
  363.                           pData[x*3+y*nSizeLine]   = pLine[x*drawable->bpp+2]; /* blue */
  364.                           pData[x*3+y*nSizeLine+1] = pLine[x*drawable->bpp+1]; /* green */
  365.                           pData[x*3+y*nSizeLine+2] = pLine[x*drawable->bpp];   /* red */
  366.                           /*pData[x+y*drawable->width*3+3] = 0;*/          /* reserved */
  367.                       }
  368.                   }
  369.               }
  370.  
  371.               g_free(pLine);
  372.               bRet = TRUE;
  373.           } /* (pLine) */
  374.           else
  375.               g_warning("Failed to get line buffer");
  376.  
  377.           GlobalUnlock(hDIB);
  378.       } /* (pData) */
  379.       else
  380.           g_warning("Failed to lock DIB Data");
  381.     } /* copy data to DIB */
  382.  
  383.     /* copy DIB to ClipBoard */
  384.     if (bRet)      
  385.     {
  386.       if (!OpenClipboard(NULL))
  387.       {
  388.           g_warning( "Cannot open the Clipboard!" );
  389.           bRet = FALSE;
  390.       }
  391.       else
  392.       {
  393.           if (bRet &&  !EmptyClipboard())
  394.           {
  395.               g_warning( "Cannot empty the Clipboard" );
  396.               bRet = FALSE;
  397.           }
  398.           if (bRet)
  399.           {
  400.               if (NULL != SetClipboardData(CF_DIB, hDIB))
  401.                   hDIB = NULL; /* data now owned by clipboard */
  402.               else
  403.                   g_warning ("Failed to set clipboard data ");
  404.               
  405.           }
  406.  
  407.           if (!CloseClipboard())
  408.               g_warning("Failed to close Clipboard");
  409.       }
  410.     }
  411.     /* done */
  412.     if (hDIB) GlobalFree(hDIB);
  413.  
  414.     gimp_drawable_detach (drawable);
  415.  
  416.     return bRet;
  417. } /* CB_CopyImage */
  418.  
  419. static int
  420. CB_PasteImage (gboolean interactive,
  421.                gint32   image_ID,
  422.                gint32   drawable_ID)
  423. {
  424.     UINT fmt;
  425.     BOOL bRet=TRUE;
  426.     HANDLE hDIB;
  427.     gint32 nWidth  = 0;
  428.     gint32 nHeight = 0;
  429.     gint32 nBitsPS = 0;
  430.     gint32 nColors = 0;
  431.  
  432.     if (!OpenClipboard(NULL))
  433.     {
  434.         g_warning("Failed to open clipboard");
  435.         return FALSE;
  436.     }
  437.  
  438.     fmt = EnumClipboardFormats(0);
  439.     while ((CF_BITMAP != fmt) && (CF_DIB != fmt) && (0 != fmt))
  440.         fmt = EnumClipboardFormats(fmt);
  441.  
  442.     if (0 == fmt) 
  443.     {
  444.         g_message("Unsupported format or Clipboard empty!");
  445.         bRet = FALSE;
  446.     }
  447.  
  448.     /* there is something supported */
  449.     if (bRet) 
  450.     {
  451.         hDIB = GetClipboardData(CF_DIB);
  452.  
  453.         if (NULL == hDIB)
  454.         {
  455.             g_warning("Can't get Clipboard data");
  456.             bRet = FALSE;
  457.         }
  458.     }
  459.  
  460.     /* read header */
  461.     if (bRet && hDIB) 
  462.     {
  463.         BITMAPINFOHEADER* pInfo;
  464.  
  465.         pInfo = GlobalLock(hDIB);
  466.         if (NULL == pInfo)
  467.         {
  468.             g_warning("Can't lock clipboard data!");
  469.             bRet = FALSE;
  470.         }
  471.  
  472.         if ((bRet) &&
  473.             ((pInfo->biSize != sizeof(BITMAPINFOHEADER)
  474.              || (pInfo->biCompression != BI_RGB))))
  475.         {
  476.             g_warning("Unupported bitmap format!");
  477.             bRet = FALSE;
  478.         }
  479.  
  480.         if (bRet && pInfo) 
  481.         {
  482.             nWidth  = pInfo->biWidth;
  483.             nHeight = pInfo->biHeight;
  484.             nBitsPS = pInfo->biBitCount;
  485.             nColors = pInfo->biClrUsed;
  486.         }
  487.  
  488.         GlobalUnlock(hDIB);
  489.     }
  490.  
  491.     if ((0 != nWidth) && (0 != nHeight))
  492.     {
  493.         GimpDrawable* drawable;
  494.         GimpPixelRgn pixel_rgn;
  495.         char* pData;
  496.         GimpParam *params;
  497.         gint retval;
  498.         gboolean bIsNewImage = TRUE;
  499.         gint oldBPP=0;
  500.  
  501.         /* Check if clipboard data and existing image are compatible */
  502.         if (IMAGE_NONE != drawable_ID)
  503.         {
  504.             drawable = gimp_drawable_get(drawable_ID);
  505.             oldBPP = drawable->bpp;
  506.             gimp_drawable_detach(drawable);
  507.         }
  508.  
  509.         if ((IMAGE_NONE == image_ID)
  510.             || (3 != oldBPP) || (24 != nBitsPS))
  511.         {
  512.             /* create new image */
  513.             image_ID = gimp_image_new (nWidth, nHeight, nBitsPS <= 8 ? GIMP_INDEXED : GIMP_RGB);
  514.             gimp_image_undo_disable(image_ID);
  515.             drawable_ID = gimp_layer_new (image_ID, _("Background"), nWidth, nHeight, 
  516.                                           nBitsPS <= 8 ? GIMP_INDEXED_IMAGE : GIMP_RGB_IMAGE, 
  517.                                           100, GIMP_NORMAL_MODE);
  518.         }
  519.         else
  520.         {
  521.             /* ??? gimp_convert_rgb(image_ID);
  522.              */
  523.             drawable_ID = gimp_layer_new (image_ID, _("Pasted"), nWidth, nHeight, 
  524.                                           nBitsPS <= 8 ? GIMP_INDEXED_IMAGE : GIMP_RGB_IMAGE, 
  525.                                           100, GIMP_NORMAL_MODE);
  526.             bIsNewImage = FALSE;
  527.         }
  528.         
  529.         gimp_image_add_layer(image_ID,drawable_ID,-1);
  530.         drawable = gimp_drawable_get(drawable_ID);
  531.  
  532.         gimp_pixel_rgn_init(&pixel_rgn, drawable, 0, 0, drawable->width, drawable->height, FALSE, FALSE);
  533.  
  534.         /* following the slow part ... */
  535.         if (interactive)
  536.             gimp_progress_init ( _("Pasting..."));
  537.  
  538.         pData = GlobalLock(hDIB);
  539.         if (pData)
  540.         {
  541.             guchar* pLine;
  542.             RGBQUAD* pPal;
  543.             int nSizeLine=0; /* DIB lines are 32 bit aligned */
  544.  
  545.             nSizeLine = ((nWidth*(nBitsPS/8)-1)/4+1)*4;
  546.  
  547.             /* adjust pointer */
  548.             pPal  = (RGBQUAD*)(pData + sizeof(BITMAPINFOHEADER));
  549.             pData = (guchar*)pPal  + sizeof(RGBQUAD) * nColors;
  550.  
  551.             /*  create palette */
  552.             if (0 != nColors)
  553.             {
  554.                 int c;
  555.                 guchar* cmap;
  556.  
  557.                 cmap = g_new(guchar, nColors*3);
  558.                 if (cmap)
  559.                 {
  560.                     for (c = 0; c < nColors; c++)
  561.                     {
  562.                         cmap[c*3]   = pPal[c].rgbRed;
  563.                         cmap[c*3+1] = pPal[c].rgbGreen;
  564.                         cmap[c*3+2] = pPal[c].rgbBlue;
  565.                     }
  566.                     gimp_image_set_cmap(image_ID, cmap, nColors);
  567.                     g_free(cmap);
  568.                 }
  569.             }
  570.  
  571.             /* speed it up with: */
  572.             gimp_tile_cache_size(  drawable->width * gimp_tile_height() 
  573.                                     * drawable->bpp );
  574.             
  575.             /* change data format and copy data */
  576.             if (24 == nBitsPS)
  577.             {
  578.                 pLine = g_new(guchar, drawable->width*drawable->bpp);
  579.                 if (pLine)
  580.                 {
  581.                     int y;
  582.                     for (y = 0; y < drawable->height; y++)
  583.                     {
  584.                         int x;
  585.  
  586.                         if ((interactive) && (StepProgress(y,drawable->height)))
  587.                             gimp_progress_update((double)y / drawable->height);
  588.  
  589.                         for (x = 0; x < drawable->width; x++)
  590.                         {
  591.                             pLine[x*drawable->bpp]   = pData[y*nSizeLine+x*3+2];
  592.                             pLine[x*drawable->bpp+1] = pData[y*nSizeLine+x*3+1];
  593.                             pLine[x*drawable->bpp+2] = pData[y*nSizeLine+x*3];
  594.                         }
  595.                         /* copy data to GIMP */
  596.                         gimp_pixel_rgn_set_rect(&pixel_rgn, pLine, 0, drawable->height-1-y, drawable->width, 1);
  597.                     }
  598.                     g_free(pLine);
  599.                 }
  600.             }
  601.             else if (8 == nBitsPS)
  602.             {
  603.                 int y;
  604.                 /* copy line by line */
  605.                 for (y = 0; y < drawable->height; y++)
  606.                 {
  607.                     if ((interactive) && (StepProgress(y,drawable->height)))
  608.                         gimp_progress_update((double)y / drawable->height);
  609.  
  610.                     pLine = pData + y*nSizeLine; /* adjust pointer */
  611.                     gimp_pixel_rgn_set_row(&pixel_rgn, pLine, 0, drawable->height-1-y, drawable->width);
  612.                 }
  613.             }
  614.             else
  615.             {
  616.                 /* copy and shift bits */
  617.                 g_message("%d bits per sample not yet supported!", nBitsPS);
  618.             }
  619.               
  620.         }
  621.         
  622.         gimp_drawable_flush(drawable);
  623.         gimp_drawable_detach(drawable);
  624.  
  625.         /* Don't miss to display the new image!
  626.          */
  627.         if (bIsNewImage)
  628.             gimp_display_new (image_ID);
  629.         else
  630.         {
  631.             gimp_layer_set_visible(drawable_ID, TRUE);
  632.             gimp_displays_flush();
  633.         }
  634.     }
  635.  
  636.     /* done */
  637.     /* clear clipboard? */
  638.     if (NULL != hDIB) GlobalFree(hDIB);
  639.  
  640.     CloseClipboard();
  641.     
  642.     /* shouldn't this be done by caller?? */
  643.     gimp_image_undo_enable(image_ID);
  644.     return bRet;
  645. } /* CB_PasteImage */
  646.  
  647. /*
  648.  * Local Variables:
  649.  * tab-width: 4
  650.  * End:
  651.  */
  652.