offset function

This commit is contained in:
Adam D. Ruppe 2015-09-26 15:05:21 -04:00
parent b700815aca
commit df1dadf7ba
1 changed files with 13 additions and 0 deletions

View File

@ -1917,6 +1917,19 @@ final class Image {
} else static assert(0, "fill in this info for other OSes");
}
///
int offsetForPixel(int x, int y) {
version(X11) {
auto offset = (y * width + x) * 4;
return offset;
} else version(Windows) {
auto itemsPerLine = ((cast(int) width * 3 + 3) / 4) * 4;
// remember, bmps are upside down
auto offset = itemsPerLine * (height - y - 1) + x * 3;
return offset;
} else static assert(0, "fill in this info for other OSes");
}
///
int adjustmentForNextLine() {
version(X11) {