<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>Trying to use rotate_scaled_sprite()... trouble with &#39;fixed&#39;</title>
		<link>http://www.allegro.cc/forums/view/590650</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Thu, 22 Mar 2007 13:59:57 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I can scale my bitmap, but I need to rotate it too.</p><p>The rotate_scaled_sprite() function needs a &#39;fixed&#39; argument, unlike stretch_sprite() which lets you specify the scaling in width and height. How do i convert width and height into &#39;fixed&#39; for scaling?</p><p>Thanks
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (peelemachine)</author>
		<pubDate>Wed, 21 Mar 2007 23:32:11 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p><span class="source-code"><a href="http://www.allegro.cc/manual/itofix" target="_blank"><span class="a">itofix</span></a> <a href="http://www.allegro.cc/manual/ftofix" target="_blank"><span class="a">ftofix</span></a></span>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (HoHo)</author>
		<pubDate>Wed, 21 Mar 2007 23:43:30 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I know about those, but they don&#39;t help.</p><p>I need to get two different integers into 1 fixed.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (peelemachine)</author>
		<pubDate>Wed, 21 Mar 2007 23:45:26 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Not possible. At least not what you seem to want to do.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (X-G)</author>
		<pubDate>Thu, 22 Mar 2007 00:10:00 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>There&#39;s no function for what you want to do, you&#39;ll have to write the algorithm yourself using some crazy trig I don&#39;t care to work out right now. (I&#39;m in class)
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Kibiz0r)</author>
		<pubDate>Thu, 22 Mar 2007 00:36:08 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>What exactly do you mean by &quot;two different integers&quot;?</p><p>If you&#39;re trying to combine one integer as the whole value and another as the decimal value, you could try this:</p><p><span class="source-code"><a href="http://www.allegro.cc/manual/fixed" target="_blank"><span class="a">fixed</span></a> fixed_val <span class="k3">=</span> <a href="http://www.allegro.cc/manual/ftofix" target="_blank"><span class="a">ftofix</span></a><span class="k2">(</span><span class="k2">(</span><span class="k1">float</span><span class="k2">)</span>decimal_int<span class="k3">/</span><span class="n">1000</span>.<span class="n">0f</span><span class="k3">+</span><span class="k2">(</span><span class="k1">float</span><span class="k2">)</span>whole_int<span class="k2">)</span><span class="k2">;</span></span></p><p>Though if that&#39;s the case, I&#39;d have to question your sanity for keeping track of the two separately in the first place. <img src="http://www.allegro.cc/forums/smileys/tongue.gif" alt=":P" /></p><p>--- Kris Asick (Gemini)<br />--- <a href="http://www.pixelships.con">http://www.pixelships.con</a>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Kris Asick)</author>
		<pubDate>Thu, 22 Mar 2007 00:41:57 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>All i want to do is rotate and stretch the sprite at the same time, to a specific width and height. I just want to use the function.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (peelemachine)</author>
		<pubDate>Thu, 22 Mar 2007 00:43:33 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I believe he wants to keep a sprite bounded by a certain width and height, no matter what the rotation.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Kibiz0r)</author>
		<pubDate>Thu, 22 Mar 2007 00:45:42 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
What exactly do you mean by &quot;two different integers&quot;?</p><p>If you&#39;re trying to combine one integer as the whole value and another as the decimal value
</p></div></div><p>
Thats not it at all. In fact the question is quite clear.</p><p>stretch_sprite() takes two parameters (width, height to stetch) whereas rotate_scaled_sprite() takes one parameter, the scale.</p><p>Anyway to try to answer you question, you cant scale an image like you are doing with  stretch blit, as scale requires you to do it proportionately. However you can do this:
</p><div class="source-code snippet"><div class="inner"><pre><a href="http://www.allegro.cc/manual/fixed" target="_blank"><span class="a">fixed</span></a> scale <span class="k3">=</span> <a href="http://www.allegro.cc/manual/ftofix" target="_blank"><span class="a">ftofix</span></a><span class="k2">(</span> new_sprite_height<span class="k3">/</span>actual_sprite_height<span class="k2">)</span>
</pre></div></div><p>
And use that as a parameter, although this assumes you have kept the stretching proportional. If not then you&#39;ll either have to write your own function which lets you do exactly what you are asking as it appears stretch_sprite may not have the functionality you require. Or use a more specific approximation (which you should be able to come up with on your own as mentioned a few time).
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Hard Rock)</author>
		<pubDate>Thu, 22 Mar 2007 00:49:46 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Ok, I see what you&#39;re getting at.</p><p>Well, if you&#39;re only going to scale the sprite equally on both axises at the same time, that&#39;s simple enough to do. You simply make a multiplier variable and apply that to the rotate_scaled_sprite() function for the scale argument.</p><p>However, if you want to stretch both axises independently, like you can with stretch_sprite(), you need to make a few extra steps and an extra bitmap. Do the following:</p><p>1: Make an extra bitmap (we&#39;ll call it &quot;xbitmap&quot;) large enough to fit the largest stretching your sprite will ever reach.</p><p>2: When the stretched size of the sprite changes, clear xbitmap to the masked colour for your video mode, (IE: bitmap_mask_color(xbitmap)), and then call stretch_sprite() on your sprite to draw it to the centre of xbitmap.</p><p>3: Draw xbitmap to the screen using rotate_sprite().</p><p>Does that help? Note that this method will NOT be very fast at all, since it has to detect and skip over all those empty masked pixels in xbitmap, but it&#39;s the only thing I can think of off-hand that will give you independent control over height and width. (Using rotate_scaled_sprite(), you control the overall size, not the height and width.)</p><p>--- Kris Asick (Gemini)<br />--- <a href="http://www.pixelships.com">http://www.pixelships.com</a>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Kris Asick)</author>
		<pubDate>Thu, 22 Mar 2007 00:54:14 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Does that help? Note that this method will NOT be very fast at all, since it has to detect and skip over all those empty masked pixels in xbitmap, but it&#39;s the only thing I can think of off-hand that will give you independent control over height and width.
</p></div></div><p>
<span class="source-code"><a href="http://www.allegro.cc/manual/stretch_blit" target="_blank"><span class="a">stretch_blit</span></a><span class="k2">(</span><span class="k2">)</span></span>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (gnolam)</author>
		<pubDate>Thu, 22 Mar 2007 01:21:33 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Thanks for the help you guys.</p><p>I can live with proportional scaling and rotation, so I&#39;ll use the ftofix idea. I didn&#39;t know what kind of value the &#39;fixed scale&#39; parameter needed to be, now I understand. Thanks again.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (peelemachine)</author>
		<pubDate>Thu, 22 Mar 2007 07:36:25 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p><b>gnolam:</b> ...<i>with</i> rotation. <img src="http://www.allegro.cc/forums/smileys/wink.gif" alt=";)" /></p><p>--- Kris Asick (Gemini)<br />--- <a href="http://www.pixelships.com">http://www.pixelships.com</a>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Kris Asick)</author>
		<pubDate>Thu, 22 Mar 2007 12:20:11 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>His point is that it&#39;s wasteful to stretch_sprite onto xbitmap, since the background is just going to be magic pink anyway. Using stretch_blit will be faster and produce the same result.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (X-G)</author>
		<pubDate>Thu, 22 Mar 2007 12:40:23 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
His point is that it&#39;s wasteful to stretch_sprite onto xbitmap, since the background is just going to be magic pink anyway. Using stretch_blit will be faster and produce the same result.
</p></div></div><p>

...oh yeah! <img src="http://www.allegro.cc/forums/smileys/grin.gif" alt=";D" /></p><p>I think too fast sometimes... <img src="http://www.allegro.cc/forums/smileys/rolleyes.gif" alt="::)" /></p><p>--- Kris Asick (Gemini)<br />--- <a href="http://www.pixelships.com">http://www.pixelships.com</a>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Kris Asick)</author>
		<pubDate>Thu, 22 Mar 2007 12:44:33 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>[nothing]
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Johan Peitz)</author>
		<pubDate>Thu, 22 Mar 2007 13:59:57 +0000</pubDate>
	</item>
</rss>
