Heyo!
Okay, after deleting my first thread this will be my new first one.
Once again, I'm quite new to programming, so please excuse if my problems might be caused by my wrong understanding.
My problem is the following:
I'm trying to create an Image of variable size that copies certain information from a "dummy-image". My problem occurs while trying to slice the dummy into four parts and copy each part into the corresponding corners of the new Image.
My actual try looks something like this:
NI ... The new (variable) image.
DI ... The dummy.
NW/NH ... New image Width/Height
DW/DH ... Dummy Width/Height
NI.Create(...)
NI.Copy(DI, 0, 0, rect(0, 0, DW/2, DH/2))
NI.Copy(DI, NW-DW/2, 0, rect(DW/2, 0, DW/2, DH/2))
NI.Copy(DI, 0, NH-DH/2, rect(0, DH/2, DW/2, DH/2))
NI.Copy(DI, (NW-DW/2)-2, NH-DH/2, rect(DW/2, DH/2, DW/2, DH/2))
The dummy looks like this:
And the code is creating this:
The crash seems to be caused by the last line (responsible for the box in the lower right corner). Like this, there is an offset of 2 pixels being drawn, but if I change the
(NW-DW/2)-2
in the last line into
NW-DW/2
the program will crash.
Am I handling the coordinates wrong? If so, why does it work perfectly fine for the other three boxes?
I'm using SFML2 on Windows 7 64 Bit.
Perde
Oh, the last line from the actual code:
ImgBackground.Copy(*DummyBackground, (ImgBackground.GetWidth() - DummyBackground->GetWidth()/2)-2, ImgBackground.GetHeight() - DummyBackground->GetHeight()/2, sf::IntRect(DummyBackground->GetWidth()/2, DummyBackground->GetHeight()/2, DummyBackground->GetWidth()/2, DummyBackground->GetHeight()/2));