|
Direct access to a pointer to bitmap |
Kajkacz
Member #16,680
May 2017
|
Hey guys! |
Audric
Member #907
January 2001
|
There is al_get_pixel() to read from graphic memory. |
Polybios
Member #12,293
October 2010
|
If you don't use a memory bitmap, your data resides on the GPU side of things. Therefore, you should use bitmap locking, as reading / writing from/to the GPU is slow to do per-pixel. What it does is to cache (parts of) the bitmap in memory (CPU side of things). From there, you can also access the data directly via the ALLEGRO_LOCKED_REGION. See al_lock_bitmap, al_unlock_bitmap and ALLEGRO_LOCKED_REGION. |
Chris Katko
Member #1,881
January 2002
|
Related question: What would be the fastest way to get array-level access to memory? I want to basically compare every single pixel on a bitmap structure. I was just trying this last week and noticed everything is in floats... if I could use integer comparisons that'd be probably a thousand times faster. Are the al_unmap_rgb/al_get_pixel functions all doing various checks and color space conversions? All I want is read access to values. -----sig: |
Polybios
Member #12,293
October 2010
|
In theory, the fastest way would probably be to do it directly on the GPU in parallel. |
Kajkacz
Member #16,680
May 2017
|
Audric, I am doing a school project where we have to use a mix of C and intel assembler.So I need to pass to the assembler function a pointer to the beggining of a pixel array.I will than use it to do the affine transforms |
Edgar Reynaldo
Major Reynaldo
May 2007
|
Allegro 5 will give you access to a memory copy of the video memory. That's what happens when you lock a video bitmap. An ALLEGRO_LOCKED_REGION has a pointer to the data, a format, a pitch, and a pixel size. You use these to read and write the data. Don't assume pitch is equivalent to pixel size times line width. It may differ, it may be different, or it may be negative. You probably want to lock the region in a 24 or 32 bit format. Allegro will convert the bitmap to and from the format you lock it in. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
Audric
Member #907
January 2001
|
In case the docs don't make it clear, "pitch" lets you know how to access lines after the first. Edgar refers to how lines can have padding between them (for memory alignment), or be arranged top to bottom. |
Polybios
Member #12,293
October 2010
|
@Kajkacz: |
|