Last active
August 29, 2015 14:12
-
-
Save ttdonovan/8bb2c4c7a09e8bbb9cea to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::os; | |
#[allow(unused_variables)] | |
fn main() { | |
let width = 2u8; | |
let height = 3u8; | |
let size = 4u8; | |
let pitch = width * size; | |
let (mut x_offset, mut y_offset) = (0u8, 0u8); | |
let chunk = match os::MemoryMap::new((width * height * size) as uint, &[ | |
os::MapOption::MapReadable, | |
os::MapOption::MapWritable | |
]) { | |
Ok(chunk) => chunk, | |
Err(msg) => panic!("{}", msg) | |
}; | |
let row = &chunk; // uint8 *Row = (uint8 *)BitmapMemory; | |
while y_offset <= 10 { | |
for y in range(0u8, height) { | |
let pixel = row; // uint32 *Pixel = (uint32 *)Row; | |
for x in range(0u8, width) { | |
let red: u8 = 0u8; | |
let green: u8 = y + y_offset; | |
let blue: u8 = x + x_offset; | |
// *Pixel++ = ((Green << 8) | Blue); | |
println!("Green: {} | Blue: {} | Red: {} = {}", green, blue, red, (red | (green << 4) | blue)); | |
} | |
// Row += Pitch; | |
// println!("{:p}", row); | |
} | |
x_offset += 1; | |
y_offset += 2; | |
}; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
internal void | |
RenderWeirdGradient(int BlueOffset, int GreenOffset) | |
{ | |
int Width = BitmapWidth; | |
int Height = BitmapHeight; | |
int Pitch = Width*BytesPerPixel; | |
uint8 *Row = (uint8 *)BitmapMemory; | |
for(int Y = 0; | |
Y < BitmapHeight; | |
++Y) | |
{ | |
uint32 *Pixel = (uint32 *)Row; | |
for(int X = 0; | |
X < BitmapWidth; | |
++X) | |
{ | |
uint8 Blue = (X + BlueOffset); | |
uint8 Green = (Y + GreenOffset); | |
*Pixel++ = ((Green << 8) | Blue); | |
} | |
Row += Pitch; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment