-
stretchblt flip
I am trying to make a stretchblt ...thing to be able to flip an image based on a variable
what i have so far is
[code]
StretchBlt Me.hdc, .Left, .Top, .Width, .Height, picSmileyMask.hdc, picSmiley.ScaleWidth * .Hflip, picSmiley.ScaleHeight * .Vflip, picSmileyMask.ScaleWidth * ((-2 * .Hflip) + 1), picSmileyMask.ScaleHeight * ((-2 * .Vflip) + 1), vbSrcPaint
StretchBlt Me.hdc, .Left, .Top, .Width, .Height, picSmiley.hdc, picSmiley.ScaleWidth * .Hflip, picSmiley.ScaleHeight * .Vflip, picSmiley.ScaleWidth * ((-2 * .Hflip) + 1), picSmiley.ScaleHeight * ((-2 * .Vflip) + 1), vbSrcAnd
[code]
the problem is i am using Vflip and Hflip variables with 1 = flip on that axis and 0 being unfliped on tht axis, it wors relativley well but whenever i flip something i get a black line on the side of the image, i checked everything and i dont know why, I desparatly need help because this will enable me to complete my game that i am making. (Yes the game is that important)
-
Re: stretchblt flip
Code:
...picSmiley.ScaleWidth * .Hflip, picSmiley.ScaleHeight * .Vflip...
Here lies your problem. With negative numbers, you should add one (I think). To cheat this feature, you could do:
Code:
... picSmiley.ScaleWidth * .Hflip + Abs(CBool(.Hflip - 1)), picSmiley.ScaleHeight * .Vflip + Abs(CBool(.Hflip - 1)), ...
Code explained:
If Hflip = 1
Hflip - 1 = 0
Convert Hflip to Boolean (CBool) -> Hflip = False (0)
Take negative indicator out of Hflip (Abs) -> Hflip = 0
If Hflip = -1
Hflip - 1 = -2
Convert Hflip to Boolean (CBool) -> Hflip = True (-1)
Take negative indicator out of Hflip (Abs) -> Hflip = 1
Hope it works :)
Edit Though your code seems a bit mess to me... it might be possible to somehow make it look simpler and yet be faster. Oh well, if you get any more problems we'll check it out better :)
-
Re: stretchblt flip
Yes my code can be a lot simpler, i am trying to make a public sub so that at least i dont have to deal with it, i may not be able to change the code right now but i have never seen cbool function before, could you please explain a bit more, if it is what it appears to be and changes numbers into boolean then can you change boolean into numbers.
Thanks for the help
and are those dashes supposed to be negative signs, im a bit confused :confused:
-
Re: stretchblt flip
That is what I'm actually doing there, I'm changing numbers into booleans and then changing booleans back to numbers. VB can do this automatically as well (the conversion of datatypes from one to another), but it is faster to define explicitly what datatype to use and when.
The dashes there are because I didn't want to copypaste the whole line there as it is pretty long, the code is like a cut from the middle. You can just ignore them.
-
Re: stretchblt flip
Haha take that StretchBlt
Got it to work
and just so you know what i did to fix it:
the part that you said to change was the problem(thx) but all i had to do was put - hflip or -vfilp right after and it corrected itself
thats for the other stuff though, it is very useful