ID:1528893
 
(See the best response by Ter13.)
Is this possible? Basically, here's the senario. We have a .jpeg image we resized in code. Basically, we want to take the resized image and turn it with the icon Turn() proc. Problem is, turn only works for non-squared object. Is there a way we can turn it while not making the card (the card is the object being turned) look like a box?



Best response
You need to temporarily increase the bounds of the icon:

var/icon/i = icon('card.dmi')
var/w = i.Width()
var/h = i.Height()
var/sz = max(w,h)
i.Crop(1,1,sz,sz)
i.Turn(90)
var/x = sz - h + 1
var/y = sz - w + 1
i.Crop(x,y,h,w)


The trick is to crop it into a square, calculate the added area for each axis, then turn it, then crop it back into a rectangle.

Although, honestly, this approach is going to be slower than using the new v500 features. Check this out:

var/matrix/m = matrix()
m.Turn(90)
card.transform = m


See how much easier that is? And you don't have to incur the CPU overhead of modifying a new icon, it doesn't add to the dyn.rsc, and on top of that, it's less work for you.
Yeah, transforms are definitely the way to go for this -- unless you need to save the results somewhere outside of the game, then you have to use icon manipulation.