diff --git a/rdoc-sources/FXImage.rb b/rdoc-sources/FXImage.rb
index 8023a36f9d2ccf11e76267e963d039aba6d036cf..04328355a210209244c2b4bcb9d6644a2ccb4791 100755
--- a/rdoc-sources/FXImage.rb
+++ b/rdoc-sources/FXImage.rb
@@ -65,6 +65,24 @@ module Fox
     def initialize(a, pixels=nil, opts=0, width=1, height=1) # :yields: theImage
     end
 
+    #
+    # Populate the image with new pixel data of the same size or of a new size
+    #
+    # Pixel data is copied and IMAGE_OWNED option is set.
+    # If called with +width+ and +height+, the size of the serverside representation
+    # of the image, if it exists, is adjusted but the contents are not updated yet.
+    # This can be done by calling render().
+    #
+    # ==== Parameters:
+    #
+    # +pix+::  the array of FXColor values.
+    # +opts+::    image options [Integer]
+    # +width+::   image width [Integer]
+    # +height+::    image height [Integer]
+    #
+    def setData(pix, opts=0, width=nil, height=nil)
+    end
+
     #
     # Return the color of the pixel at (_x_, _y_).
     #
diff --git a/swig-interfaces/FXImage.i b/swig-interfaces/FXImage.i
index 7bec3bd13755e1e6a667bd7bdd5a817562d28ac7..98156887c68e8bd30ec43da888d1ef294d0c89e7 100644
--- a/swig-interfaces/FXImage.i
+++ b/swig-interfaces/FXImage.i
@@ -86,21 +86,33 @@ public:
   /// Change options
   void setOptions(FXuint opts);
 
-  /**
-  * Populate the image with new pixel data of the same size; it will assume
-  * ownership of the pixel data if image IMAGE_OWNED option is passed.
-  * The server-side representation of the image, if it exists, is not updated.
-  * This can be done by calling render().
-  */
-  virtual void setData(FXColor *pix,FXuint opts=0);
-
-  /**
-  * Populate the image with new pixel data of a new size; it will assume ownership
-  * of the pixel data if image IMAGE_OWNED option is passed.  The size of the server-
-  * side representation of the image, if it exists, is adjusted but the contents are
-  * not updated yet. This can be done by calling render().
-  */
-  virtual void setData(FXColor *pix,FXuint opts,FXint w,FXint h);
+  %extend {
+    /**
+    * Populate the image with new pixel data of the same size; it will assume
+    * ownership of the pixel data if image IMAGE_OWNED option is passed.
+    * The server-side representation of the image, if it exists, is not updated.
+    * This can be done by calling render().
+    */
+    void setData(VALUE ary,FXuint opts=0,VALUE w=Qnil,VALUE h=Qnil){
+      FXColor* pix=0;
+      Check_Type(ary,T_ARRAY);
+      if( ( (NIL_P(w) || NIL_P(h)) && self->getWidth()*self->getHeight() != RARRAY_LEN(ary)) ||
+          (!(NIL_P(w) || NIL_P(h)) && NUM2UINT(w)*NUM2UINT(h) != RARRAY_LEN(ary))){
+        rb_raise( rb_eArgError, "array size does not match image size" );
+      }
+      if(FXMALLOC(&pix,FXColor,RARRAY_LEN(ary))){
+        for(long i=0; i<RARRAY_LEN(ary); i++){
+          pix[i]=static_cast<FXColor>(NUM2UINT(rb_ary_entry(ary,i)));
+        }
+      }
+      opts|=IMAGE_OWNED;
+      if( NIL_P(w) || NIL_P(h) ){
+        self->setData(pix,opts);
+      }else{
+        self->setData(pix,opts,NUM2UINT(w),NUM2UINT(h));
+      }
+    }
+  }
 
   /// Get pixel at x,y
   FXColor getPixel(FXint x,FXint y) const;
diff --git a/test/TC_FXImage.rb b/test/TC_FXImage.rb
index 64f6c882fbdaed08866cab9ea0cd9108bb9ec7fa..2db33a06b95583b4fbf1175bfed9807300d4ab67 100755
--- a/test/TC_FXImage.rb
+++ b/test/TC_FXImage.rb
@@ -59,6 +59,22 @@ class TC_FXImage < Fox::TestCase
     assert_equal(IMAGE_OWNED, img.options)
   end
 
+  def test_setData
+    img = FXImage.new(app, nil, 0, 2, 2)
+    img.setData([0x12345678, 2, 3, 4])
+    assert_equal(IMAGE_OWNED, img.options)
+    assert_equal(2*2, img.data.size)
+    assert_equal([0x12345678, 2, 3, 4], img.data.to_a)
+  end
+
+  def test_setData2
+    img = FXImage.new(app)
+    img.setData([0x12345678, 2], 0, 2, 1)
+    assert_equal(IMAGE_OWNED, img.options)
+    assert_equal(2*1, img.data.size)
+    assert_equal([0x12345678, 2], img.data.to_a)
+  end
+
   def test_create
     #
     # If the image owns its pixel data and IMAGE_KEEP was not specified,