1. ----------------------------------------------------------------------- 
  2. --               GtkAda - Ada95 binding for Gtk+/Gnome               -- 
  3. --                                                                   -- 
  4. --                Copyright (C) 2000-2013, AdaCore                   -- 
  5. --                                                                   -- 
  6. -- This library is free software; you can redistribute it and/or     -- 
  7. -- modify it under the terms of the GNU General Public               -- 
  8. -- License as published by the Free Software Foundation; either      -- 
  9. -- version 2 of the License, or (at your option) any later version.  -- 
  10. --                                                                   -- 
  11. -- This library is distributed in the hope that it will be useful,   -- 
  12. -- but WITHOUT ANY WARRANTY; without even the implied warranty of    -- 
  13. -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU -- 
  14. -- General Public License for more details.                          -- 
  15. --                                                                   -- 
  16. -- You should have received a copy of the GNU General Public         -- 
  17. -- License along with this library; if not, write to the             -- 
  18. -- Free Software Foundation, Inc., 59 Temple Place - Suite 330,      -- 
  19. -- Boston, MA 02111-1307, USA.                                       -- 
  20. --                                                                   -- 
  21. -- As a special exception, if other files instantiate generics from  -- 
  22. -- this unit, or you link this unit with other files to produce an   -- 
  23. -- executable, this  unit  does not  by itself cause  the resulting  -- 
  24. -- executable to be covered by the GNU General Public License. This  -- 
  25. -- exception does not however invalidate any other reasons why the   -- 
  26. -- executable file  might be covered by the  GNU Public License.     -- 
  27. ----------------------------------------------------------------------- 
  28.  
  29. --  <description> 
  30. --  This object provides image manipulation routines. 
  31. -- 
  32. --  The following image formats are known, but some depend on external 
  33. --  libraries for the proper loading of files (indicated with * in the list): 
  34. --     PNG*, JPEG*, TIFF*, GIF, XPM, PNM, Sun raster file (ras), ico, 
  35. --     bmp. 
  36. -- 
  37. --  With this package, you can load images from file, display them on the 
  38. --  screen, re-scale them and compose them with other images. 
  39. --  All the functions fully support alpha channels (opacity). 
  40. -- 
  41. --  Different filters are provided, depending on the quality of output you 
  42. --  expect and the speed you need. 
  43. --  </description> 
  44. --  <c_version>1.3.11</c_version> 
  45. --  <group>Gdk, the low-level API</group> 
  46. --  <testgtk>create_pixbuf.adb</testgtk> 
  47.  
  48. with Interfaces.C.Strings; 
  49. with System; 
  50.  
  51. with Glib; use Glib; 
  52. with Glib.Error; use Glib.Error; 
  53. with Glib.Object; 
  54. with Gdk.Bitmap; 
  55. with Gdk.Drawable; 
  56. with Gdk.Color; 
  57. with Gdk.Cursor; 
  58. with Gdk.Display; 
  59. with Gdk.GC; 
  60. with Gdk.Pixmap; 
  61. with Gdk.Rgb; 
  62.  
  63. package Gdk.Pixbuf is 
  64.  
  65.    type Gdk_Pixbuf_Record is new Glib.Object.GObject_Record with private; 
  66.  
  67.    type Gdk_Pixbuf is access all Gdk_Pixbuf_Record'Class; 
  68.    --  A very efficient client-side pixmap. 
  69.    --  This type can be adapted to all the possible screen depths (number of 
  70.    --  bits per pixel), and the algorithms are extremely efficient. 
  71.    --  You can also load a pixbuf directly from an external file in one of 
  72.    --  the standard image formats. 
  73.  
  74.    Null_Pixbuf : constant Gdk_Pixbuf := null; 
  75.  
  76.    type Gdk_Pixbuf_Animation is new Glib.C_Proxy; 
  77.    --  Type used for animations. 
  78.  
  79.    type Gdk_Pixbuf_Animation_Iter is new Glib.C_Proxy; 
  80.    --  Type used to iterate through an animation. 
  81.  
  82.    type Alpha_Mode is (Alpha_Bilevel, Alpha_Full); 
  83.    --  Alpha compositing mode. 
  84.    --  This indicates how the alpha channel (for opacity) is handled when 
  85.    --  rendering. 
  86.    pragma Convention (C, Alpha_Mode); 
  87.  
  88.    type Gdk_Colorspace is (Colorspace_RGB); 
  89.    --  Type of the image. 
  90.    --  The only possible value is currently RGB, but extensions will 
  91.    --  exist with CMYK, Gray, Lab, ... 
  92.    pragma Convention (C, Gdk_Colorspace); 
  93.  
  94.    type Gdk_Interp_Type is 
  95.      (Interp_Nearest, 
  96.       --  Nearest neighbor. It is the fastest and lowest quality. 
  97.  
  98.       Interp_Tiles, 
  99.       --  Accurate simulation of the Postscript image operator 
  100.       --  without any interpolation enabled; each pixel is rendered as a tiny 
  101.       --  parallelogram of solid color, the edges of which are implemented 
  102.       --  with anti-aliasing. It resembles nearest neighbor for enlargement, 
  103.       --  and bilinear for reduction. 
  104.  
  105.       Interp_Bilinear, 
  106.       --  Bilinear interpolation. For enlargement, it is equivalent to 
  107.       --  point-sampling the ideal bilinear-interpolated image. For reduction, 
  108.       --  it is equivalent to laying down small tiles and integrating over the 
  109.       --  coverage area. 
  110.  
  111.       Interp_Hyper 
  112.       --  Filter_Hyper is the highest quality reconstruction function. It is 
  113.       --  derived from the hyperbolic filters in Wolberg's "Digital Image 
  114.       --  Warping," and is formally defined as the hyperbolic-filter sampling 
  115.       --  the ideal hyperbolic-filter interpolated image (the filter is 
  116.       --  designed to be idempotent for 1:1 pixel mapping). It is the slowest 
  117.       --  and highest quality. 
  118.      ); 
  119.    --  Interpolation methods. 
  120.    pragma Convention (C, Gdk_Interp_Type); 
  121.  
  122.    ------------ 
  123.    -- Errors -- 
  124.    ------------ 
  125.  
  126.    --  Errors defined in the Pixbuf_Error domain: 
  127.  
  128.    Corrupt_Image         : constant := 0; 
  129.    --  image data hosed 
  130.  
  131.    Insufficient_Memory   : constant := 1; 
  132.    --  no mem to load image 
  133.  
  134.    Bad_Option            : constant := 2; 
  135.    --  bad option passed to save routine 
  136.  
  137.    Unknown_Type          : constant := 3; 
  138.    --  unsupported image type 
  139.  
  140.    Unsupported_Operation : constant := 4; 
  141.    --  unsupported operation (load, save) for image type 
  142.  
  143.    Failed                : constant := 5; 
  144.    --  Operation failed. 
  145.  
  146.    type File_Format is (JPEG, PNG, ICO, BMP); 
  147.    --  Possible formats when saving a file. 
  148.  
  149.    type Image_Quality is range 0 .. 100; 
  150.    --  For a JPEG image only, quality of the image in percentage. 
  151.  
  152.    type Alpha_Range is range 0 .. 255; 
  153.    --  Valid values for alpha parameters. 
  154.    pragma Convention (C, Alpha_Range); 
  155.  
  156.    -------------- 
  157.    -- Get_Type -- 
  158.    -------------- 
  159.  
  160.    function Get_Type return Glib.GType; 
  161.    --  Return the internal value associated with a Gdk_Pixbuf. 
  162.  
  163.    -------------------------- 
  164.    -- Accessing the fields -- 
  165.    -------------------------- 
  166.  
  167.    function Get_Colorspace (Pixbuf : Gdk_Pixbuf) return Gdk_Colorspace; 
  168.    --  Query the color space of a pixbuf. 
  169.  
  170.    function Get_N_Channels (Pixbuf : Gdk_Pixbuf) return Gint; 
  171.    --  Number of channels in the image. 
  172.  
  173.    function Get_Has_Alpha (Pixbuf : Gdk_Pixbuf) return Boolean; 
  174.    --  Return True if the image has an alpha channel (opacity information). 
  175.  
  176.    function Get_Bits_Per_Sample (Pixbuf : Gdk_Pixbuf) return Gint; 
  177.    --  Number of bits per color sample. 
  178.  
  179.    function Get_Pixels (Pixbuf : Gdk_Pixbuf) return Gdk.Rgb.Rgb_Buffer_Access; 
  180.    --  Return a pointer to the pixel data of the image. 
  181.  
  182.    function Get_Width (Pixbuf : Gdk_Pixbuf) return Gint; 
  183.    --  Return the width of the image in pixels. 
  184.  
  185.    function Get_Height (Pixbuf : Gdk_Pixbuf) return Gint; 
  186.    --  Return the height of the image in pixels. 
  187.  
  188.    function Get_Rowstride (Pixbuf : Gdk_Pixbuf) return Gint; 
  189.    --  Return the number of bytes between rows in the image data. 
  190.  
  191.    -------------- 
  192.    -- Creating -- 
  193.    -------------- 
  194.  
  195.    function Gdk_New 
  196.      (Colorspace      : Gdk_Colorspace := Colorspace_RGB; 
  197.       Has_Alpha       : Boolean := False; 
  198.       Bits_Per_Sample : Gint := 8; 
  199.       Width           : Gint; 
  200.       Height          : Gint) return Gdk_Pixbuf; 
  201.    --  Create a blank pixbuf with an optimal row stride and a new buffer. 
  202.    --  The buffer is allocated, but not cleared. 
  203.    --  The reference counting is initialized to 1. 
  204.  
  205.    function Copy (Pixbuf : Gdk_Pixbuf) return Gdk_Pixbuf; 
  206.    --  Copy a pixbuf. 
  207.  
  208.    function Gdk_New_Subpixbuf 
  209.      (Src_Pixbuf : Gdk_Pixbuf; 
  210.       Src_X      : Gint; 
  211.       Src_Y      : Gint; 
  212.       Width      : Gint; 
  213.       Height     : Gint) return Gdk_Pixbuf; 
  214.    --  Create a pixbuf which points to the pixels of another pixbuf 
  215.  
  216.    procedure Gdk_New_From_File 
  217.      (Pixbuf   : out Gdk_Pixbuf; 
  218.       Filename : String; 
  219.       Error    : out GError); 
  220.    --  Load an image from file. 
  221.  
  222.    function Gdk_New_From_Data 
  223.      (Data              : Guchar_Array_Access; 
  224.       Colorspace        : Gdk_Colorspace := Colorspace_RGB; 
  225.       Has_Alpha         : Boolean := False; 
  226.       Bits_Per_Sample   : Gint := 8; 
  227.       Width             : Gint; 
  228.       Height            : Gint; 
  229.       Rowstride         : Gint; 
  230.       Auto_Destroy_Data : Boolean := True) return Gdk_Pixbuf; 
  231.    --  Create a pixbuf out of in-memory image data. 
  232.    --  Currently only RGB images with 8 bits per sample are supported. 
  233.    --  Width and Height must be > 0. 
  234.    --  Rowstride is the distance in bytes between row starts. 
  235.    --  A typical value is 4*Width when there is an Alpha channel. 
  236.    --  If Auto_Destroy_Data is true, passed data will be automatically 
  237.    --  freed when the reference count of the pixbuf reaches 1. 
  238.    --  Otherwise, data is never freed. 
  239.  
  240.    function Gdk_New_From_Xpm_Data 
  241.      (Data : Interfaces.C.Strings.chars_ptr_array) return Gdk_Pixbuf; 
  242.    --  Create an image from a XPM data. 
  243.  
  244.    procedure Fill (Pixbuf : Gdk_Pixbuf; Pixel : Guint32); 
  245.    --  Fill pixbuf with a given pixel value. 
  246.  
  247.    procedure Save 
  248.      (Pixbuf   : Gdk_Pixbuf; 
  249.       Filename : String; 
  250.       Format   : File_Format; 
  251.       Error    : out GError; 
  252.       Quality  : Image_Quality := Image_Quality'Last; 
  253.       Depth    : Integer := 32); 
  254.    --  Save pixbuf to a file. 
  255.    --  Quality is only taken into account for JPEG images. 
  256.    --  Depth is only taken into account for ICO images and can take the values 
  257.    --  16, 24 or 32. 
  258.    --  Error is set to null on success, and set to a GError otherwise. 
  259.  
  260.    function Add_Alpha 
  261.      (Pixbuf           : Gdk_Pixbuf; 
  262.       Substitute_Color : Boolean := False; 
  263.       Red              : Guchar := 0; 
  264.       Green            : Guchar := 0; 
  265.       Blue             : Guchar := 0) return Gdk_Pixbuf; 
  266.    --  Add an alpha channel. 
  267.    --  Return a newly allocated image copied from Pixbuf, but with an 
  268.    --  extra alpha channel. 
  269.    --  If Pixbuf already had an alpha channel, the two images have exactly 
  270.    --  the same contents. 
  271.    --  If Substitute_Color is True, the color (Red, Green, Blue) is 
  272.    --  substituted for zero opacity. 
  273.    --  If Substitute_Color is False, Red, Green and Blue are ignored, and a 
  274.    --  new color is created with zero opacity. 
  275.  
  276.    procedure Copy_Area 
  277.      (Src_Pixbuf  : Gdk_Pixbuf; 
  278.       Src_X       : Gint; 
  279.       Src_Y       : Gint; 
  280.       Width       : Gint; 
  281.       Height      : Gint; 
  282.       Dest_Pixbuf : Gdk_Pixbuf; 
  283.       Dest_X      : Gint; 
  284.       Dest_Y      : Gint); 
  285.    --  Copy a rectangular area from Src_pixbuf to Dest_pixbuf. 
  286.    --  Conversion of pixbuf formats is done automatically. 
  287.  
  288.    procedure Saturate_And_Pixelate 
  289.      (Src        : Gdk_Pixbuf; 
  290.       Dest       : Gdk_Pixbuf; 
  291.       Saturation : Gfloat; 
  292.       Pixelate   : Boolean := True); 
  293.    --  Brighten/darken and optionally make it pixelated-looking. 
  294.  
  295.    --------------- 
  296.    -- Rendering -- 
  297.    --------------- 
  298.  
  299.    procedure Render_Threshold_Alpha 
  300.      (Pixbuf          : Gdk_Pixbuf; 
  301.       Bitmap          : Gdk.Bitmap.Gdk_Bitmap; 
  302.       Src_X           : Gint; 
  303.       Src_Y           : Gint; 
  304.       Dest_X          : Gint; 
  305.       Dest_Y          : Gint; 
  306.       Width           : Gint; 
  307.       Height          : Gint; 
  308.       Alpha_Threshold : Alpha_Range); 
  309.    --  Take the opacity values in a rectangular portion of a pixbuf and 
  310.    --  thresholds them to produce a bi-level alpha mask that can be used as 
  311.    --  a clipping mask for a drawable. 
  312.    --  Bitmap is the bitmap where the bilevel mask will be painted to. 
  313.    --  Alpha_Threshold are the opacity values below which a pixel will be 
  314.    --  painted as zero. All other values will be painted as one. 
  315.  
  316.    procedure Render_To_Drawable 
  317.      (Pixbuf   : Gdk_Pixbuf; 
  318.       Drawable : Gdk.Drawable.Gdk_Drawable; 
  319.       GC       : Gdk.GC.Gdk_GC; 
  320.       Src_X    : Gint; 
  321.       Src_Y    : Gint; 
  322.       Dest_X   : Gint; 
  323.       Dest_Y   : Gint; 
  324.       Width    : Gint; 
  325.       Height   : Gint; 
  326.       Dither   : Gdk.Rgb.Gdk_Rgb_Dither := Gdk.Rgb.Dither_Normal; 
  327.       X_Dither : Gint := 0; 
  328.       Y_Dither : Gint := 0); 
  329.    --  Render a rectangular portion of a pixbuf to a drawable while using the 
  330.    --  specified GC. This is done using Gdk.RGB, so the specified drawable 
  331.    --  must have the Gdk.RGB visual and colormap.  Note that this function 
  332.    --  will ignore the opacity information for images with an alpha channel; 
  333.    --  the GC must already have the clipping mask set if you want transparent 
  334.    --  regions to show through. 
  335.    -- 
  336.    --  For an explanation of dither offsets, see the Gdk.RGB documentation.  In 
  337.    --  brief, the dither offset is important when re-rendering partial regions 
  338.    --  of an image to a rendered version of the full image, or for when the 
  339.    --  offsets to a base position change, as in scrolling.  The dither matrix 
  340.    --  has to be shifted for consistent visual results.  If you do not have 
  341.    --  any of these cases, the dither offsets can be both zero. 
  342.  
  343.    procedure Render_To_Drawable_Alpha 
  344.      (Pixbuf          : Gdk_Pixbuf; 
  345.       Drawable        : Gdk.Drawable.Gdk_Drawable; 
  346.       Src_X           : Gint; 
  347.       Src_Y           : Gint; 
  348.       Dest_X          : Gint; 
  349.       Dest_Y          : Gint; 
  350.       Width           : Gint; 
  351.       Height          : Gint; 
  352.       Alpha           : Alpha_Mode; 
  353.       Alpha_Threshold : Alpha_Range; 
  354.       Dither          : Gdk.Rgb.Gdk_Rgb_Dither := Gdk.Rgb.Dither_Normal; 
  355.       X_Dither        : Gint := 0; 
  356.       Y_Dither        : Gint := 0); 
  357.    --  Render a rectangular portion of a pixbuf to a drawable. 
  358.    --  This is done using Gdk.RGB, so the specified drawable must have the 
  359.    --  Gdk_RGB visual and colormap. When used with Alpha_Bilevel, this function 
  360.    --  has to create a bitmap out of the thresholded alpha channel of the 
  361.    --  image and, it has to set this bitmap as the clipping mask for the GC 
  362.    --  used for drawing.  This can be a significant performance penalty 
  363.    --  depending on the size and the complexity of the alpha channel of the 
  364.    --  image. If performance is crucial, consider handling the alpha channel 
  365.    --  yourself (possibly by caching it in your application) and using 
  366.    --  Render_To_Drawable or Gdk.RGB directly instead. 
  367.    -- 
  368.    --  If the image does have opacity information and Alpha_Mode 
  369.    --  is Alpha_Bilevel, specifies the threshold value for opacity values 
  370.  
  371.    procedure Render_Pixmap_And_Mask 
  372.      (Pixbuf          : Gdk_Pixbuf; 
  373.       Pixmap          : out Gdk.Pixmap.Gdk_Pixmap; 
  374.       Mask            : out Gdk.Bitmap.Gdk_Bitmap; 
  375.       Alpha_Threshold : Alpha_Range); 
  376.    procedure Render_Pixmap_And_Mask_For_Colormap 
  377.      (Pixbuf          : Gdk_Pixbuf; 
  378.       Colormap        : Gdk.Color.Gdk_Colormap; 
  379.       Pixmap          : out Gdk.Pixmap.Gdk_Pixmap; 
  380.       Mask            : out Gdk.Bitmap.Gdk_Bitmap; 
  381.       Alpha_Threshold : Alpha_Range); 
  382.    --  Creates a pixmap and a mask bitmap which are returned in the Pixmap 
  383.    --  and Mask arguments, respectively, and renders a pixbuf and its 
  384.    --  corresponding tresholded alpha mask to them.  This is merely a 
  385.    --  convenience function; applications that need to render pixbufs with 
  386.    --  dither offsets or to given drawables should use Render_To_Drawable_Alpha 
  387.    --  or Render_To_Drawable 
  388.    --  The pixmap that is created uses Colormap. 
  389.    --  This colormap must match the colormap of the window where the pixmap 
  390.    --  will eventually be used or an error will result. 
  391.  
  392.    function Get_From_Drawable 
  393.      (Dest   : Gdk_Pixbuf; 
  394.       Src    : Gdk.Drawable.Gdk_Drawable; 
  395.       Cmap   : Gdk.Color.Gdk_Colormap; 
  396.       Src_X  : Gint; 
  397.       Src_Y  : Gint; 
  398.       Dest_X : Gint; 
  399.       Dest_Y : Gint; 
  400.       Width  : Gint; 
  401.       Height : Gint) return Gdk_Pixbuf; 
  402.    --  Transfer image data from a Gdk drawable and converts it to an RGB(A) 
  403.    --  representation inside a Gdk_Pixbuf. 
  404.    -- 
  405.    --  If the drawable src is a pixmap, then a suitable colormap must be 
  406.    --  specified, since pixmaps are just blocks of pixel data without an 
  407.    --  associated colormap. 
  408.    --  If the drawable is a window, the Cmap argument will be ignored and the 
  409.    --  window's own colormap will be used instead. 
  410.    -- 
  411.    --  If the specified destination pixbuf Dest is Null_Pixbuf, then this 
  412.    --  function will create an RGB pixbuf with 8 bits per channel and no 
  413.    --  alpha, with the same size specified by the Width and Height 
  414.    --  arguments. In this case, the Dest_x and Dest_y arguments must be 
  415.    --  specified as 0, otherwise the function will return Null_Pixbuf.  If the 
  416.    --  specified destination pixbuf is not Null_Pixbuf and it contains alpha 
  417.    --  information, then the filled pixels will be set to full opacity. 
  418.    -- 
  419.    --  If the specified drawable is a pixmap, then the requested source 
  420.    --  rectangle must be completely contained within the pixmap, otherwise the 
  421.    --  function will return Null_Pixbuf. 
  422.    -- 
  423.    --  If the specified drawable is a window, then it must be viewable, i.e. 
  424.    --  all of its ancestors up to the root window must be mapped.  Also, the 
  425.    --  specified source rectangle must be completely contained within the 
  426.    --  window and within the screen.  If regions of the window are obscured by 
  427.    --  non-inferior windows, the contents of those regions are undefined. 
  428.    --  The contents of regions obscured by inferior windows of a different 
  429.    --  depth than that of the source window will also be undefined. 
  430.    -- 
  431.    --  Return value: The same pixbuf as Dest if it was non-NULL, or a 
  432.    --  newly-created pixbuf with a reference count of 1 if no destination 
  433.    --  pixbuf was specified. 
  434.  
  435.    ------------- 
  436.    -- Scaling -- 
  437.    ------------- 
  438.  
  439.    procedure Scale 
  440.      (Src          : Gdk_Pixbuf; 
  441.       Dest         : Gdk_Pixbuf; 
  442.       Dest_X       : Gint; 
  443.       Dest_Y       : Gint; 
  444.       Dest_Width   : Gint; 
  445.       Dest_Height  : Gint; 
  446.       Offset_X     : Gdouble := 0.0; 
  447.       Offset_Y     : Gdouble := 0.0; 
  448.       Scale_X      : Gdouble := 1.0; 
  449.       Scale_Y      : Gdouble := 1.0; 
  450.       Inter_Type   : Gdk_Interp_Type := Interp_Bilinear); 
  451.    --  Transform the source image by scaling by Scale_x and Scale_y then 
  452.    --  translating by Offset_x and Offset_y. 
  453.    --  The image is then rendered in the rectangle (Dest_x, Dest_y, 
  454.    --  Dest_width, Dest_height) of the resulting image onto the destination 
  455.    --  drawable replacing the previous contents. 
  456.  
  457.    procedure Composite 
  458.      (Src           : Gdk_Pixbuf; 
  459.       Dest          : Gdk_Pixbuf; 
  460.       Dest_X        : Gint; 
  461.       Dest_Y        : Gint; 
  462.       Dest_Width    : Gint; 
  463.       Dest_Height   : Gint; 
  464.       Offset_X      : Gdouble := 0.0; 
  465.       Offset_Y      : Gdouble := 0.0; 
  466.       Scale_X       : Gdouble := 1.0; 
  467.       Scale_Y       : Gdouble := 1.0; 
  468.       Inter_Type    : Gdk_Interp_Type := Interp_Bilinear; 
  469.       Overall_Alpha : Alpha_Range := 128); 
  470.    --  Transform the source image by scaling by Scale_X and Scale_Y then 
  471.    --  translating by Offset_X and Offset_Y, then composite the rectangle 
  472.    --  (Dest_X, Dest_Y, Dest_Width, Dest_Height) of the resulting image onto 
  473.    --  the destination drawable. 
  474.  
  475.    procedure Composite_Color 
  476.      (Src           : Gdk_Pixbuf; 
  477.       Dest          : Gdk_Pixbuf; 
  478.       Dest_X        : Gint; 
  479.       Dest_Y        : Gint; 
  480.       Dest_Width    : Gint; 
  481.       Dest_Height   : Gint; 
  482.       Offset_X      : Gdouble := 0.0; 
  483.       Offset_Y      : Gdouble := 0.0; 
  484.       Scale_X       : Gdouble := 1.0; 
  485.       Scale_Y       : Gdouble := 1.0; 
  486.       Inter_Type    : Gdk_Interp_Type := Interp_Bilinear; 
  487.       Overall_Alpha : Alpha_Range := 128; 
  488.       Check_X       : Gint := 0; 
  489.       Check_Y       : Gint := 0; 
  490.       Check_Size    : Gint := 0; 
  491.       Color1        : Guint32 := 0; 
  492.       Color2        : Guint32 := 0); 
  493.    --  Transform the source image by scaling by Scale_x and Scale_y then 
  494.    --  translating by Offset_x and Offset_y, then composites the rectangle 
  495.    --  (Dest_X, Dest_Y, Dest_Width, Dest_Height) of the resulting image with 
  496.    --  a checkboard of the colors Color1 and Color2 and renders it onto the 
  497.    --  destination drawable. 
  498.    --  The origin of checkboard is at (Check_x, Check_y) 
  499.    --  Color1 is the color at the upper left of the check. 
  500.  
  501.    function Scale_Simple 
  502.      (Src           : Gdk_Pixbuf; 
  503.       Dest_Width    : Gint; 
  504.       Dest_Height   : Gint; 
  505.       Inter_Type    : Gdk_Interp_Type := Interp_Bilinear) return Gdk_Pixbuf; 
  506.    --  Scale the Src image to Dest_width x Dest_height and render the result 
  507.    --  into a new pixbuf. 
  508.  
  509.    function Composite_Color_Simple 
  510.      (Src           : Gdk_Pixbuf; 
  511.       Dest_Width    : Gint; 
  512.       Dest_Height   : Gint; 
  513.       Inter_Type    : Gdk_Interp_Type := Interp_Bilinear; 
  514.       Overall_Alpha : Alpha_Range := 128; 
  515.       Color1        : Guint32 := 0; 
  516.       Color2        : Guint32 := 0) return Gdk_Pixbuf; 
  517.    --  Scale Src to Dest_width x Dest_height and composite the result with 
  518.    --  a checkboard of colors Color1 and Color2 and render the result into 
  519.    --  a new pixbuf. 
  520.  
  521.    ----------------------- 
  522.    -- Animation support -- 
  523.    ----------------------- 
  524.  
  525.    function Get_Type_Animation return Glib.GType; 
  526.    --  Return the internal value associated with a Gdk_Pixbuf_Animation. 
  527.  
  528.    procedure Gdk_New_From_File 
  529.      (Animation : out Gdk_Pixbuf_Animation; 
  530.       Filename  : String; 
  531.       Error     : out GError); 
  532.    --  Create a new animation by loading it from a file. 
  533.    --  The file format is detected automatically. If the file's format does not 
  534.    --  support multi-frame images, then an animation with a single frame will 
  535.    --  be created. Possible errors are in the Pixbuf_Error and GFile_Error 
  536.    --  domains. 
  537.    --  On return, Animation is a newly created animation with a reference count 
  538.    --  of 1, or null if any of several error conditions ocurred: the file could 
  539.    --  not be opened, there was no loader for the file's format, there was not 
  540.    --  enough memory to allocate the image buffer, or the image file contained 
  541.    --  invalid data. 
  542.  
  543.    procedure Ref (Animation : Gdk_Pixbuf_Animation); 
  544.    --  Increment the reference counting on the animation. 
  545.  
  546.    procedure Unref (Animation : Gdk_Pixbuf_Animation); 
  547.    --  Decrement the reference counting on the animation. 
  548.  
  549.    function Get_Width (Animation : Gdk_Pixbuf_Animation) return Gint; 
  550.    --  Return the width of the bounding box of a pixbuf animation. 
  551.  
  552.    function Get_Height (Animation : Gdk_Pixbuf_Animation) return Gint; 
  553.    --  Return the height of the bounding box of a pixbuf animation. 
  554.  
  555.    function Is_Static_Image (Animation : Gdk_Pixbuf_Animation) return Boolean; 
  556.    --  If you load a file with Gdk_New_From_File and it turns out to be a 
  557.    --  plain, unanimated image, then this function will return True. 
  558.    --  Use Get_Static_Image to retrieve the image. 
  559.  
  560.    function Get_Static_Image 
  561.      (Animation : Gdk_Pixbuf_Animation) return Gdk_Pixbuf; 
  562.    --  If an animation is really just a plain image (has only one frame), 
  563.    --  this function returns that image. If the animation is an animation, 
  564.    --  this function returns a reasonable thing to display as a static 
  565.    --  unanimated image, which might be the first frame, or something more 
  566.    --  sophisticated. If an animation hasn't loaded any frames yet, this 
  567.    --  function will return null. 
  568.  
  569.    function Get_Iter 
  570.      (Animation  : Gdk_Pixbuf_Animation; 
  571.       Start_Time : GTime_Val_Access := null) 
  572.       return Gdk_Pixbuf_Animation_Iter; 
  573.    --  Get an iterator for displaying an animation. The iterator provides 
  574.    --  the frames that should be displayed at a given time. 
  575.    --  It should be freed after use with Unref. 
  576.    -- 
  577.    --  Start_Time would normally come from G_Get_Current_Time, and marks the 
  578.    --  beginning of animation playback. After creating an iterator, you should 
  579.    --  immediately display the pixbuf returned by Get_Pixbuf. Then, you should 
  580.    --  install a timeout (with Timeout_Add) or by some other mechanism to 
  581.    --  ensure that you'll update the image after Get_Delay_Time milliseconds. 
  582.    --  Each time the image is updated, you should reinstall the timeout with 
  583.    --  the new, possibly-changed delay time. 
  584.    -- 
  585.    --  As a shortcut, if Start_Time is equal to null, the result of 
  586.    --  G_Get_Current_Time will be used automatically. 
  587.    -- 
  588.    --  To update the image (i.e. possibly change the result of Get_Pixbuf to a 
  589.    --  new frame of the animation), call Advance. 
  590.    -- 
  591.    --  If you're using Gdk_Pixbuf_Loader, in addition to updating the image 
  592.    --  after the delay time, you should also update it whenever you 
  593.    --  receive the area_updated signal and On_Currently_Loading_Frame returns 
  594.    --  True. In this case, the frame currently being fed into the loader 
  595.    --  has received new data, so needs to be refreshed. The delay time for 
  596.    --  a frame may also be modified after an area_updated signal, for 
  597.    --  example if the delay time for a frame is encoded in the data after 
  598.    --  the frame itself. So your timeout should be reinstalled after any 
  599.    --  area_updated signal. 
  600.    -- 
  601.    --  A delay time of -1 is possible, indicating "infinite." 
  602.  
  603.    --------------- 
  604.    -- Iterators -- 
  605.    --------------- 
  606.  
  607.    function Get_Type_Animation_Iter return Glib.GType; 
  608.    --  Return the internal value associated with a Gdk_Pixbuf_Animation_Iter. 
  609.  
  610.    procedure Ref (Iter : Gdk_Pixbuf_Animation_Iter); 
  611.    --  Increment the reference counting on the iterator. 
  612.  
  613.    procedure Unref (Iter : Gdk_Pixbuf_Animation_Iter); 
  614.    --  Decrement the reference counting on the iterator. 
  615.  
  616.    function Get_Delay_Time (Iter : Gdk_Pixbuf_Animation_Iter) return Gint; 
  617.    --  Return the number of milliseconds the current pixbuf should be displayed 
  618.    --  or -1 if the current pixbuf should be displayed forever. Timeout_Add 
  619.    --  conveniently takes a timeout in milliseconds, so you can use a timeout 
  620.    --  to schedule the next update. 
  621.  
  622.    function Get_Pixbuf (Iter : Gdk_Pixbuf_Animation_Iter) return Gdk_Pixbuf; 
  623.    --  Return the current pixbuf which should be displayed. 
  624.    --  The pixbuf will be the same size as the animation itself (Get_Width, 
  625.    --  Get_Height). This pixbuf should be displayed for Get_Delay_Time 
  626.    --  milliseconds. The caller of this function does not own a reference to 
  627.    --  the returned pixbuf; the returned pixbuf will become invalid when the 
  628.    --  iterator advances to the next frame, which may happen anytime you call 
  629.    --  Advance. Copy the pixbuf to keep it (don't just add a reference), as it 
  630.    --  may get recycled as you advance the iterator. 
  631.  
  632.    function On_Currently_Loading_Frame 
  633.      (Iter : Gdk_Pixbuf_Animation_Iter) return Boolean; 
  634.    --  Used to determine how to respond to the area_updated signal on 
  635.    --  Gdk_Pixbuf_Loader when loading an animation. area_updated is emitted 
  636.    --  for an area of the frame currently streaming in to the loader. So if 
  637.    --  you're on the currently loading frame, you need to redraw the screen for 
  638.    --  the updated area. 
  639.  
  640.    function Advance 
  641.      (Iter          : Gdk_Pixbuf_Animation_Iter; 
  642.       Current_Timer : GTime_Val_Access := null) return Boolean; 
  643.    --  Possibly advance an animation to a new frame. 
  644.    --  Chooses the frame based on the start time passed to Get_Iter. 
  645.    -- 
  646.    --  Current_Time would normally come from G_Get_Current_Time, and 
  647.    --  must be greater than or equal to the time passed to Get_Iter, 
  648.    --  and must increase or remain unchanged each time Get_Pixbuf is 
  649.    --  called. That is, you can't go backward in time; animations only 
  650.    --  play forward. 
  651.    -- 
  652.    --  As a shortcut, pass null for the current time and G_Get_Current_Time 
  653.    --  will be invoked on your behalf. So you only need to explicitly pass 
  654.    --  Current_Time if you're doing something odd like playing the animation 
  655.    --  at double speed. 
  656.    -- 
  657.    --  If this function returns False, there's no need to update the animation 
  658.    --  display, assuming the display had been rendered prior to advancing; 
  659.    --  if True, you need to call Get_Pixbuf and update the display with the new 
  660.    --  pixbuf. 
  661.  
  662.    ------------- 
  663.    -- Cursors -- 
  664.    ------------- 
  665.  
  666.    procedure Gdk_New_From_Pixbuf 
  667.      (Cursor  : out Gdk.Cursor.Gdk_Cursor; 
  668.       Display : Gdk.Display.Gdk_Display := Gdk.Display.Get_Default; 
  669.       Pixbuf  : Gdk_Pixbuf; 
  670.       X       : Glib.Gint; 
  671.       Y       : Glib.Gint); 
  672.    --  Create a cursor from a pixbuf. 
  673.    --  Not all GDK backends support RGBA cursors. If they are not supported, 
  674.    --  a monochrome approximation will be displayed. 
  675.    --  The functions gdk.display.supports_cursor_alpha and 
  676.    --  gdk.display.supports_cursor_color can be used to determine whether RGBA 
  677.    --  cursors are supported; 
  678.    --  gdk.display.get_default_cursor_size and 
  679.    --  gdk.display.get_maximal_cursor_size give information about cursor sizes. 
  680.    --  On the X backend, support for RGBA cursors requires a sufficently new 
  681.    --  version of the X Render extension. 
  682.  
  683.    function Get_Image (Cursor : Gdk.Cursor.Gdk_Cursor) return Gdk_Pixbuf; 
  684.    --  Return the image stored in the cursor 
  685.  
  686.    --  <doc_ignore> 
  687.    function Convert (P : System.Address) return Gdk_Pixbuf; 
  688.    --  </doc_ignore> 
  689.  
  690. private 
  691.  
  692.    type Gdk_Pixbuf_Record is new Glib.Object.GObject_Record with null record; 
  693.  
  694.    pragma Import (C, Get_Type, "gdk_pixbuf_get_type"); 
  695.    pragma Import (C, Get_Type_Animation, "gdk_pixbuf_animation_get_type"); 
  696.    pragma Import 
  697.      (C, Get_Type_Animation_Iter, "gdk_pixbuf_animation_iter_get_type"); 
  698.    pragma Import (C, Get_Iter, "gdk_pixbuf_animation_get_iter"); 
  699.    pragma Import 
  700.      (C, Get_Delay_Time, "gdk_pixbuf_animation_iter_get_delay_time"); 
  701.  
  702. end Gdk.Pixbuf;