diff --git a/ext/fox16_c/include/FXRbImage.h b/ext/fox16_c/include/FXRbImage.h
index f2d658265cce296e36c894463ef6e1081110a4a3..c071d8d6de853ae81e572f69b277f6ca5a78918c 100644
--- a/ext/fox16_c/include/FXRbImage.h
+++ b/ext/fox16_c/include/FXRbImage.h
@@ -143,11 +143,9 @@ protected:
 #include "FXRbIdVirtuals.h"
 #include "FXRbDrawableVirtuals.h"
 #include "FXRbImageVirtuals.h"
-
-  VALUE data_string;
 public:
   /// Create an image
-  FXRbImage(FXApp* a,const FXColor* pix=NULL,FXuint opts=0,FXint w=1,FXint h=1):FXImage(a,pix,opts,w,h),data_string(Qnil){
+  FXRbImage(FXApp* a,const FXColor* pix=NULL,FXuint opts=0,FXint w=1,FXint h=1):FXImage(a,pix,opts,w,h){
     FXRbRegisterAppSensitiveObject(this);
     }
 
diff --git a/ext/fox16_c/markfuncs.cpp b/ext/fox16_c/markfuncs.cpp
index 65d2422c80cac15891e49ad717a669b93a774e67..e001bbb3da2c5df972a1a0dccc2069e1ecd43ef6 100644
--- a/ext/fox16_c/markfuncs.cpp
+++ b/ext/fox16_c/markfuncs.cpp
@@ -121,9 +121,6 @@ void FXRbIcon::markfunc(FXIcon* icon){
 
 void FXRbImage::markfunc(FXImage* image){
   FXRbDrawable::markfunc(image);
-  if( image ){
-    rb_gc_mark(dynamic_cast<FXRbImage*>(image)->data_string);
-    }
   }
 
 
diff --git a/lib/fox16/core.rb b/lib/fox16/core.rb
index 48ed0d41528b158437bc60370f4d3fd55e75b7aa..18e56bbd94d0c5ce877b59b51e95d523e688e49a 100755
--- a/lib/fox16/core.rb
+++ b/lib/fox16/core.rb
@@ -696,5 +696,19 @@ module Fox
 =end
 
   end
+
+  class FXImage
+    alias initialize_without_data_string initialize
+    def initialize(a, pix, *args)
+      initialize_without_data_string(a, pix, *args)
+      @data_string = (options & IMAGE_OWNED) != 0 ? nil : pix
+    end
+
+    alias setPixels_without_data_string setPixels
+    def setPixels(pix, *args)
+      setPixels_without_data_string(pix, *args)
+      @data_string = (options & IMAGE_OWNED) != 0 ? nil : pix
+    end
+  end
 end
 
diff --git a/swig-interfaces/FXImage.i b/swig-interfaces/FXImage.i
index d01dc08e43fdc696a0926029aa46f3c00d5e61ae..c472d7326eaaf9ef08b45bf11f92420c6f026d93 100644
--- a/swig-interfaces/FXImage.i
+++ b/swig-interfaces/FXImage.i
@@ -64,9 +64,7 @@ public:
         }
         pix=FXRbConvertToFXColors(string_or_ary, &opts);
       }
-      FXRbImage *img = new FXRbImage(a,pix,opts,w,h);
-      img->data_string = (opts & IMAGE_OWNED) ? Qnil : string_or_ary;
-      return img;
+      return new FXRbImage(a,pix,opts,w,h);
     }
 
     /// To get to the pixel data
@@ -101,7 +99,6 @@ public:
       }
 
       FXColor* pix=FXRbConvertToFXColors(string_or_ary, &opts);
-      (dynamic_cast<FXRbImage*>(self))->data_string = (opts & IMAGE_OWNED) ? Qnil : string_or_ary;
       if( NIL_P(w) || NIL_P(h) ){
         self->setData(pix,opts);
       }else{
diff --git a/test/TC_FXBMPImage.rb b/test/TC_FXBMPImage.rb
index fc95f95480332e615cc5e6ebf6e592a72b2d90da..89050f2bd27cd42cb8a71bfaeee7a994b12f0d16 100755
--- a/test/TC_FXBMPImage.rb
+++ b/test/TC_FXBMPImage.rb
@@ -12,4 +12,17 @@ class TC_FXBMPImage < Fox::TestCase
   def test_fileExt
     assert_equal("bmp", FXBMPImage.fileExt)
   end
+
+  def test_image_from_pixel_data
+    img = FXBMPImage.new app
+    img.setPixels "rgbaRGBA", 0, 1, 2
+    bmp_data = FXMemoryStream.open(FXStreamSave, nil) do |outfile|
+      img.savePixels(outfile)
+      outfile.takeBuffer
+    end
+    assert_not_equal "rgbaRGBA", bmp_data
+
+    img2 = FXBMPImage.new app, bmp_data
+    assert_equal "rgbaRGBA", img2.pixel_string
+  end
 end