diff --git a/simpledisplay.d b/simpledisplay.d index 2fb5523..bd39b94 100644 --- a/simpledisplay.d +++ b/simpledisplay.d @@ -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) {