ofImage draws as a white rectangle..

Hi all, I’m trying to build a simple Ruby layer on top of OF, I’ve wrapped some of the ofImage functionality by hand (not using SWIG or anything). I use Data_Wrap_Struct() and Data_Get_Struct() from Ruby API to wrap an ofImage instance. When I want to draw the image I call the draw method from Ruby, but only get a white square on screen with the size of the image, but not the image itself. It seems to me that some data is missing from the ofImage object but I’m not sure about that.

Here is the code that wraps ofImage:

  
  
/////////////////////////////////////////////  
  
#include <ofMain.h>  
#include <ruby.h>  
  
// Prototipos.  
VALUE AImage_new(VALUE _class);  
void AImage_free(void *p);  
  
VALUE AImage_c_load_image(VALUE self, VALUE file_name);  
  
//! Modulo Ruby Of.  
extern VALUE mOf;  
//! Clase Ruby AImage.  
VALUE cAImage;  
  
//! Funcion 'constructor' de la clase Ruby.  
/*!  
	\param _class Clase de la cual se crea una instancia.  
*/  
VALUE AImage_new(VALUE _class)  
{  
	ofImage *im = new ofImage();  
	VALUE tdata = Data_Wrap_Struct(_class, 0, AImage_free, im);  
	rb_obj_call_init(tdata, 0, 0);  
	  
	rb_iv_set(tdata, "@has_image", Qfalse);  
	  
	return tdata;  
}  
  
//! Funcion 'destructor' de la clase Ruby.  
/*!  
	\param p Puntero a la instancia C++ envuelta por Ruby.  
*/  
void AImage_free(void *p)  
{  
	delete (ofImage*)p;  
}  
  
VALUE AImage_c_load_image(VALUE self, VALUE file_name)  
{  
	ofImage *im;  
	  
	Data_Get_Struct(self, ofImage, im);  
	  
	// Cargar imagen desde disco.  
		// loadImage requiere in string de C++.  
	std::string str = rb_string_value_ptr(&file_name);  
	if(!im->loadImage(str))  
	{  
		rb_raise(rb_eRuntimeError, "AImage::initialize(): Imposible cargar el archivo '%s'.", str.c_str());  
	}  
	  
	return self;  
}  
  
//! Funcion de dibujado del objeto.  
/*!  
	\param self Instancia Ruby.  
*/  
VALUE AImage_c_draw(VALUE self)  
{  
	ofImage *im;  
	Data_Get_Struct(self, ofImage, im);  
	  
	im->draw(10, 10);  
	  
	return self;  
}  
  
//! Inicializacion de clase Ruby AImage.  
void Init_AImage()  
{  
	VALUE cAScreenObject = rb_define_class_under(mOf, "AScreenObject", rb_cObject);  
	cAImage = rb_define_class_under(mOf, "AImage", cAScreenObject);  
	rb_define_singleton_method(cAImage, "new", (VALUE(*)(ANYARGS))AImage_new, 0);  
	  
	rb_define_method(cAImage, "c_load_image", (VALUE(*)(ANYARGS))AImage_c_load_image, 1);  
	rb_define_method(cAImage, "c_draw", (VALUE(*)(ANYARGS))AImage_c_draw, 0);  
}  
/////////////////////////////////////////////  
  

Hope someone can help me and thanks in advance!!

Nevermind, I’ve fixed it.

I know it’s been a long time since this thread was posted. Would you remember how you solved it? Im getting the same issue that image.draw() is producing white pixels.

hey usama

maybe you try this in you setup: ofDisableArbTex();

or the X-size of you image is higher than 2000 something pixel…
thats what happen to me on my laptop.

greetings