SV * get_pixel32 (SDL_Surface *surface, int x, int y) { //Convert the pixels to 32 bit Uint32 *pixels = (Uint32 *)surface->pixels; //Get the requested pixel Uint32* u_ptr = pixels + ( y * surface->w ) + x ; SV* sv = newSVpv("a",1); //Make a temp SV* value on the go SvCUR_set(sv, sizeof(Uint32)); //Specify the new CUR length SvLEN_set(sv, sizeof(Uint32)); //Specify the LEN length SvPV_set(sv,(char*)u_ptr); // set the actual pixel's pointer as the memory space to use return sv; //make a modifiable reference using u_ptr's place as the memory :) }