1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 2<html xmlns="http://www.w3.org/1999/xhtml"> 3<head> 4<meta http-equiv="Content-Type" content="text/html; charset=windows-1252" /> 5<meta http-equiv="Content-Style-Type" content="text/css" /> 6<title>DSP_ScalingFx</title> 7<link rel="stylesheet" href="../../css/nitro.css" type="text/css" /> 8</head> 9<body> 10 11<h1>DSP_ScalingFx* <IMG src="../../image/TWL.gif" align="middle"></H1> 12<H2>Syntax</H2> 13 14<pre><code> 15BOOL DSP_ScalingFxAsyncEx( 16 const void* src, 17 void* dst, 18 u16 img_width, 19 u16 img_height, 20 fx32 rx, 21 fx32 ry, 22 DSPGraphicsScalingMode mode, 23 u16 x, 24 u16 y, 25 u16 width, 26 u16 height, 27 DSP_GraphicsCallback callback 28 ); 29 30BOOL DSP_ScalingFx(src, dst, img_width, img_height, rx, ry, mode); 31BOOL DSP_ScalingFxEx(src, dst, img_width, img_height, rx, ry, mode, x, y, width, height); 32BOOL DSP_ScalingFxAsync(src, dst, img_width, img_height, rx, ry, mode, callback); 33</code></pre> 34 35<h2>Arguments</h2> 36<table style="width:100%"> 37<tbody> 38<tr> 39<td style="width:13%"><em><strong>src</strong></em></td> 40<td style="width:87%">Buffer in main memory that holds the data to convert.</td> 41</tr> 42<tr> 43<td style="width:13%"><em><strong>dst</strong></em></td> 44<td style="width:87%">Buffer in main memory that will hold the converted data.<br /><span style='color:Red'>You must allocate a buffer large enough to store the converted data.</span></td> 45</tr> 46<tr> 47<td style="width:13%"><em><strong>img_width</strong></em></td> 48<td style="width:87%">Width of the image to convert.</td> 49</tr> 50<tr> 51<td style="width:13%"><em><strong>img_height</strong></em></td> 52<td style="width:87%">Height of the image to convert.</td> 53</tr> 54<tr> 55<td style="width:13%"><em><strong>rx</strong></em></td> 56<td style="width:87%">Horizontal scaling factor.<br /><span style='color:Red'>This is valid between 31 and 0.001. Decimals will be truncated to three decimal places.</span></td> 57</tr> 58<tr> 59<td style="width:13%"><em><strong>ry</strong></em></td> 60<td style="width:87%">Vertical scaling factor.<br /> <span style='color:Red'>This is valid between 31 and 0.001. Decimals will be truncated to three decimal places.</span> 61</td> 62</tr> 63<tr> 64<td style="width:13%"><em><strong>mode</strong></em></td> 65<td style="width:87%">Interpolation method for scaling up (expanding) or scaling down (shrinking). Specifies the <CODE>DSPGraphicsScalingMode</CODE> (described below).</td> 66</tr> 67<tr> 68<td style="width:13%"><em><strong>x</strong></em></td> 69<td style="width:87%">X-coordinate of the region to process, with the coordinate system origin (0,0) located at the upper-left of <CODE>src</CODE>.</td> 70</tr> 71<tr> 72<td style="width:13%"><em><strong>y</strong></em></td> 73<td style="width:87%">Y-coordinate of the region to process, with the coordinate system origin (0,0) located at the upper-left of <CODE>src</CODE>.</td> 74</tr> 75<tr> 76<td style="width:13%"><em><strong>width</strong></em></td> 77<td style="width:87%">Width of the region to process.</td> 78</tr> 79<tr> 80<td style="width:13%"><em><strong>height</strong></em></td> 81<td style="width:87%">Height of the region to process.</td> 82</tr> 83<tr> 84<td style="width:13%"><em><strong>callback</strong></em></td> 85<td style="width:87%">Callback function when processing ends.</td> 86</tr> 87</tbody> 88</table> 89 90<h2>Return Values</h2> 91<p>Returns <CODE>TRUE</CODE> when processing ends normally.<br>Returns <CODE>FALSE</CODE> when conversion did not end normally or the graphics component is already processing something.</p> 92 93<h2>Description</h2> 94<p>Uses the DSP to expand or shrink image data.</p> 95 96<p>The addresses indicated by <SPAN class="argument">src</SPAN> and <SPAN class="argument">dst</SPAN> must be 4-byte aligned.</p> 97<p>Data is transferred between main memory and the DSP (WRAM-C) using the AHB. Data transfers between main memory and the DSP run at a lower priority than DMA data transfers, so AHB arbitration causes delays if another process uses frequent DMA transfers while scaling is being processed.</p> 98 99<p>Factors are specified as fixed-point numbers (<CODE>fx32</CODE>). Due to underflow that can occur during decimal calculations, the converted size may differ from the intended value. However, you can use the <code><a href="DSP_Macro.html">DSP_CALC_SCALING_SIZE_FX</a></code> macro to get the converted size that results from the <CODE>DSP_ScalingFx*</CODE> functions. We have provided a function, <a href="DSP_CalcScalingFactor.html"><code>DSP_CalcScalingFactorFx32</code></a>, that takes the converted size as an argument and can get the factors to pass to this function. 100</p> 101 102<p> 103The interpolation method used while processing is defined by <CODE>DSPGraphicsScalingMode</CODE> as follows. 104</p> 105<pre><code> 106typedef DSPWord DSPGraphicsScalingMode; 107#define DSP_GRAPHICS_SCALING_MODE_N_NEIGHBOR (DSPGraphicsScalingMode)0x0001 108#define DSP_GRAPHICS_SCALING_MODE_BILINEAR (DSPGraphicsScalingMode)0x0002 109#define DSP_GRAPHICS_SCALING_MODE_BICUBIC (DSPGraphicsScalingMode)0x0003 110</code></pre> 111<p>Starting from the top, these represent nearest-neighbor, bilinear, and bicubic interpolation. As a basic rule, processing time increases as you move down the list. 112</p> 113 114<p>When the asynchronous versions of this function (<CODE>*Async</CODE>) are run, the callback function registered as an argument will be invoked to send a notification that conversion has finished. <span style='color:Red'>Callback functions are invoked by interrupts from the DSP, so callbacks will never return if interrupts have been prohibited by a function such as <code><A href="../../os/irq/OS_DisableIrq.html">OS_DisableIrq</A></code>. Do not disable DSP interrupts from another process while asynchronous versions of this function are running.</span> 115</p> 116 117<p>With the <CODE>*Ex</CODE> versions of this function, you can specify an arbitrary region of the source image and process only that region. 118</p> 119 120<h2>Note</h2> 121<p>In the synchronous version, the <code>OS_Sleep</code> function waits for the process to complete. Therefore, call the <code><A href="../../os/thread/OS_InitThread.html">OS_InitThread</A>, <A href="../../os/time/OS_InitTick.html">OS_InitTick</A>, and <A href="../../os/alarm/OS_InitAlarm.html">OS_InitAlarm</A></code> functions beforehand.</p> 122 123<h2>See Also</h2> 124<p><code><a href="DSP_LoadGraphics.html">DSP_LoadGraphics</a><BR> <a href="DSP_UnloadGraphics.html">DSP_UnloadGraphics</a><BR> <a href="DSP_Scaling.html">DSP_Scaling*</a><BR> <a href="../../os/irq/OS_DisableIrq.html">OS_DisableIrq</a><BR> <a href="DSP_Macro.html">DSP_CALC_SCALING_SIZE_FX</a><BR> <a href="DSP_CalcScalingFactor.html">DSP_CalcScalingFactor*</a><BR> <a href="../../fx/fx32.html">fx32</a></code></p> 125 126<h2>Revision History</h2> 127<p> 1282008/10/22 Added a note in line with internal changes to synchronous functions.<br> 2008/09/06 Added information about the data transfer method.<br> 2008/08/28 Initial version. 129</p> 130<hr><p>CONFIDENTIAL</p></body> 131</html> 132