I have a project right know where I may have the need to manipulate pixels in a BITMAP and I wonder which is the most efficient way of doing so. I know there are getpixel and putpixel funcions, but I wonder if accessing directly to the BITMAP struct would be a better approach, and also if there are any hints on how doing so as best as possible.

Also, making distinction between A4 and A5 would be great, since I will soon be switching to A5 and would be great to be able to port everything to it.

I suppose that the type of BITMAP (memory, video) will also have an impact...

As described in this thread amongst others: https://www.allegro.cc/forums/thread/614217/0, the fastest way to directly access pixels in Allegro5 is to use al_lock_bitmap(). However, nowadays almost all common platforms have a GPU, pixel per pixel access is not the best way to do graphics. In stead, use al_draw_bitmap() or the primitives extension, this will be translated under the hood into much faster OpenGL or Direct3D calls.

I'm aware that nowadays this is kind of retro and not very recommendable, but among other things, I want to impart some lessons about game programming starting by pixel pushing in a framebuffer, as in old DOS days.

Simulating it by writing pixels to a texture would do... it's just that I need to find a nice and clean way to do it, I don't want to choose the worst way.

“Throughout history, poverty is the normal condition of man. Advances which permit this norm to be exceeded — here and there, now and then — are the work of an extremely small minority, frequently despised, often condemned, and almost always opposed by all right-thinking people. Whenever this tiny minority is kept from creating, or (as sometimes happens) is driven out of a society, the people then slip back into abject poverty. This is known as "bad luck.”