summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob L. Kreuze <jakob@memeware.net>2018-06-11 21:58:42 -0400
committerJakob L. Kreuze <jakob@memeware.net>2018-06-11 21:58:42 -0400
commitfe14bab96a780a2980cc6f51135ebd5dfa79667e (patch)
tree7aad25de793068c6a285e330c0969d1bf26e65d8
parent91abcae9e7ca9b80474d93410fbd87c747f7f658 (diff)
Partially fixed palette issue and bitmap orientation.
-rw-r--r--src/bitmap.rs16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/bitmap.rs b/src/bitmap.rs
index a6651f5..afc78c5 100644
--- a/src/bitmap.rs
+++ b/src/bitmap.rs
@@ -103,12 +103,12 @@ impl BitmapManager {
// FIXME: As of right now it's RGB, not ARGB.
for i in 0..256 {
- let r = data[i] as u32;
- let g = data[i + 1] as u32;
- let b = data[i + 2] as u32;
+ let r = data[(i * 3)] as u32;
+ let g = data[(i * 3) + 1] as u32;
+ let b = data[(i * 3) + 2] as u32;
// FIXME: Also, I'm not a fan of this manual shifting shit.
- palette.push(r << 4 | g << 2 | b);
+ palette.push(r << 4 | g << 2 | b << 0);
}
palette
@@ -270,8 +270,12 @@ impl BitmapManager {
let mut data = Vec::new();
- for index in indices.iter() {
- data.push(palette[*index as usize]);
+ // FIXME: Casting this as usize is just nasty, man.
+ for column in 0..width {
+ for row in 0..height {
+ let index = indices[(row as usize) * (width as usize) + (column as usize)];
+ data.push(palette[index as usize]);
+ }
}
bitmaps.push(Bitmap { width, height, data });