Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdint.h>
- //:For Example, in non-toy code don't allocate on
- //:the stack like this.
- #define WID 32
- #define HIG 64
- #define RGBA 4
- uint8_t img[ WID * HIG * RGBA ]={ 0 };
- //:Y loop on outside to traverse pixels in order,
- //:which should help prevent cache misses.
- for( int y = 0 ; y <=( HIG-1 ) ; y ++ ){
- for( int x = 0 ; x <=( WID-1 ) ; x ++ ){
- //: xy to index formula ://
- int i =( x + ( y * WID ) );
- //:Set a pixel:
- img[ (i*RGBA)+0 ]=( 0xFF ) ; //:Set Red ://
- img[ (i*RGBA)+1 ]=( 0x44 ) ; //:Set Green://
- img[ (i*RGBA)+2 ]=( 0x12 ) ; //:Set Blue ://
- img[ (i*RGBA)+3 ]=( 255 ) ; //:Set Alpha://
- };;};;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement