No, you can’t just replace the pointer! (Think about it: The image could be using openGL or some other native format!)
The docs for that class are pretty clear:
/** Retrieves a section of an image as raw pixel data, so it can be read or written to.
You should only use this class as a last resort - messing about with the internals of
an image is only recommended for people who really know what they're doing!
A BitmapData object should be used as a temporary, stack-based object. Don't keep one
hanging around while the image is being used elsewhere.
Depending on the way the image class is implemented, this may create a temporary buffer
which is copied back to the image when the object is deleted, or it may just get a pointer
directly into the image's raw data.
You can use the stride and data values in this class directly, but don't alter them!
The actual format of the pixel data depends on the image's format - see Image::getFormat(),
and the PixelRGB, PixelARGB and PixelAlpha classes for more info.
…not sure what you’re struggling with?
Yes, you do copy your own data to it, but don’t use memcpy!
You need to take into account pixel format, pixel stride and line-stride, so unless you handle every edge-case yourself, the safest method is to just use Image::BitmapData::setPixelColour to write to it, which is probably fast enough for most use-cases. (And if you have LTO then the compiler may even be able to inline that method and hoist its loop invariants which would make it pretty much optimal code anyway)