SFML community forums
Bindings - other languages => DotNet => Topic started by: nihohit on April 10, 2012, 11:00:38 am
-
I'm working in SFML.net and I'm trying to create images from image tiles. Sometimes I need to rotate the tiles, and since I'm trying to create new images, and I can't do it on the Sprite level. I tried writing code to do it manually, but the code fails without an error message on the SetPixel command. Anyone got any idea why?
private static Image rotate270
(Image temp
) { uint maxY
= temp
.Size.Y; uint maxX
= temp
.Size.X; Image val
= new Image
(maxY, maxX
); for (uint x
= 0; x
< maxX
; x
++) { for (uint y
= 0; y
< maxY
; y
++) { val
.SetPixel(y, maxX
- x, temp
.GetPixel(x, y
)); } } return val
; } private static Image rotate90
(Image temp
) { uint maxY
= temp
.Size.Y; uint maxX
= temp
.Size.X; Image val
= new Image
(maxY, maxX
); for (uint x
= 0; x
< maxX
; x
++) { for (uint y
= 0; y
< maxY
; y
++) { val
.SetPixel(maxY
-y, x, temp
.GetPixel(x, y
)); } } return val
; } private static Image rotate180
(Image temp
) { uint maxY
= temp
.Size.Y; uint maxX
= temp
.Size.X; Image val
= new Image
(maxX, maxY
); for (uint x
= 0; x
< maxX
; x
++) { for (uint y
= 0; y
< maxY
; y
++) { val
.SetPixel(maxX
-x, maxY
-y, temp
.GetPixel(x, y
)); } } return val
; }
-
maxX - x == maxX when x == 0, and row maxX is invalid (the last one is maxX - 1). Same for Y.
-
OUCH. I feel really stupid for that.
Sorry for the hassle.