Manipulate an image already in memory with Rust

Hi, I need to replicate the situation of this topic in the GameMaker forum.

Basically, I can interact with an external library (dll for x86 that I made in rust). The problem is that the only parameters allowed in and out are ty_string and ty_real (so strings and doubles).
The idea is to pass the buffer address to rust in order to manipulate it in Rust by accessing the memory with the pointer. Unfortunately I am not able to do this yet, as I have just started using Rust.
So I'm asking for help, both to solve this problem, and to find a library that allows me to manipulate this image freely (the purpose of all this is to increase performance to be able to run some procedural algorithm, such as cellular automata for example).

The code from GameMaker that calls the Rust library:

image_width_ = camera_get_view_width(view_camera[0]);
image_height_ = camera_get_view_height(view_camera[0]);
surface_ = surface_create(image_width_, image_height_);
surface_set_target(surface_);
draw_clear_alpha(c_black, 0);
surface_reset_target();

buffer_ = buffer_create(image_width_ * image_height_ * 4, buffer_fixed, 1);
buffer_get_surface(buffer_, surface_, 0);
buffer_address_ = buffer_get_address(buffer_);

dll_work_on_surface_ = external_define(
	"procgen.dll", 
	"work_on_surface", 
	dll_cdecl, 
	ty_real, 
	3,
	ty_string,
	ty_real,
	ty_real);

call_result_ = external_call(
	dll_work_on_surface_, 
	buffer_address_, 
	image_width_, 
	image_height_);

The code in Rust

#[no_mangle]
pub extern "C" fn work_on_surface(
    p_buffer: *mut u8,
    width: c_double,
    height: c_double)  -> c_double
{
    // Help!!!

    return 1 as c_double;
}

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.