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