Graphical demo for the LPC4088 Experiment Base Board with one of the Display Expansion Kits. This program displays how to write text in different fonts.

Dependencies:   EALib mbed

Committer:
embeddedartists
Date:
Thu Jun 25 10:30:15 2015 +0000
Revision:
0:5e5e9ec91fc8
First version

Who changed what in which revision?

UserRevisionLine numberNew contents of line
embeddedartists 0:5e5e9ec91fc8 1 /*
embeddedartists 0:5e5e9ec91fc8 2 * @brief SWIM image management
embeddedartists 0:5e5e9ec91fc8 3 *
embeddedartists 0:5e5e9ec91fc8 4 * @note
embeddedartists 0:5e5e9ec91fc8 5 * Copyright(C) NXP Semiconductors, 2012
embeddedartists 0:5e5e9ec91fc8 6 * All rights reserved.
embeddedartists 0:5e5e9ec91fc8 7 *
embeddedartists 0:5e5e9ec91fc8 8 * @par
embeddedartists 0:5e5e9ec91fc8 9 * Software that is described herein is for illustrative purposes only
embeddedartists 0:5e5e9ec91fc8 10 * which provides customers with programming information regarding the
embeddedartists 0:5e5e9ec91fc8 11 * LPC products. This software is supplied "AS IS" without any warranties of
embeddedartists 0:5e5e9ec91fc8 12 * any kind, and NXP Semiconductors and its licensor disclaim any and
embeddedartists 0:5e5e9ec91fc8 13 * all warranties, express or implied, including all implied warranties of
embeddedartists 0:5e5e9ec91fc8 14 * merchantability, fitness for a particular purpose and non-infringement of
embeddedartists 0:5e5e9ec91fc8 15 * intellectual property rights. NXP Semiconductors assumes no responsibility
embeddedartists 0:5e5e9ec91fc8 16 * or liability for the use of the software, conveys no license or rights under any
embeddedartists 0:5e5e9ec91fc8 17 * patent, copyright, mask work right, or any other intellectual property rights in
embeddedartists 0:5e5e9ec91fc8 18 * or to any products. NXP Semiconductors reserves the right to make changes
embeddedartists 0:5e5e9ec91fc8 19 * in the software without notification. NXP Semiconductors also makes no
embeddedartists 0:5e5e9ec91fc8 20 * representation or warranty that such application will be suitable for the
embeddedartists 0:5e5e9ec91fc8 21 * specified use without further testing or modification.
embeddedartists 0:5e5e9ec91fc8 22 *
embeddedartists 0:5e5e9ec91fc8 23 * @par
embeddedartists 0:5e5e9ec91fc8 24 * Permission to use, copy, modify, and distribute this software and its
embeddedartists 0:5e5e9ec91fc8 25 * documentation is hereby granted, under NXP Semiconductors' and its
embeddedartists 0:5e5e9ec91fc8 26 * licensor's relevant copyrights in the software, without fee, provided that it
embeddedartists 0:5e5e9ec91fc8 27 * is used in conjunction with NXP Semiconductors microcontrollers. This
embeddedartists 0:5e5e9ec91fc8 28 * copyright, permission, and disclaimer notice must appear in all copies of
embeddedartists 0:5e5e9ec91fc8 29 * this code.
embeddedartists 0:5e5e9ec91fc8 30 */
embeddedartists 0:5e5e9ec91fc8 31
embeddedartists 0:5e5e9ec91fc8 32 #include "lpc_types.h"
embeddedartists 0:5e5e9ec91fc8 33 #include "lpc_swim_image.h"
embeddedartists 0:5e5e9ec91fc8 34
embeddedartists 0:5e5e9ec91fc8 35 /*****************************************************************************
embeddedartists 0:5e5e9ec91fc8 36 * Private types/enumerations/variables
embeddedartists 0:5e5e9ec91fc8 37 ****************************************************************************/
embeddedartists 0:5e5e9ec91fc8 38
embeddedartists 0:5e5e9ec91fc8 39 /*****************************************************************************
embeddedartists 0:5e5e9ec91fc8 40 * Public types/enumerations/variables
embeddedartists 0:5e5e9ec91fc8 41 ****************************************************************************/
embeddedartists 0:5e5e9ec91fc8 42
embeddedartists 0:5e5e9ec91fc8 43 /*****************************************************************************
embeddedartists 0:5e5e9ec91fc8 44 * Private functions
embeddedartists 0:5e5e9ec91fc8 45 ****************************************************************************/
embeddedartists 0:5e5e9ec91fc8 46
embeddedartists 0:5e5e9ec91fc8 47 /*****************************************************************************
embeddedartists 0:5e5e9ec91fc8 48 * Public functions
embeddedartists 0:5e5e9ec91fc8 49 ****************************************************************************/
embeddedartists 0:5e5e9ec91fc8 50
embeddedartists 0:5e5e9ec91fc8 51 /* Puts a raw image into a window */
embeddedartists 0:5e5e9ec91fc8 52 void swim_put_image(SWIM_WINDOW_T *win,
embeddedartists 0:5e5e9ec91fc8 53 const COLOR_T *image,
embeddedartists 0:5e5e9ec91fc8 54 int32_t xsize,
embeddedartists 0:5e5e9ec91fc8 55 int32_t ysize)
embeddedartists 0:5e5e9ec91fc8 56 {
embeddedartists 0:5e5e9ec91fc8 57 int32_t x, y;
embeddedartists 0:5e5e9ec91fc8 58
embeddedartists 0:5e5e9ec91fc8 59 /* Unknown values of rtype will do no rotation */
embeddedartists 0:5e5e9ec91fc8 60 y = win->ypvmin;
embeddedartists 0:5e5e9ec91fc8 61
embeddedartists 0:5e5e9ec91fc8 62 xsize = xsize + win->xpvmin;
embeddedartists 0:5e5e9ec91fc8 63 ysize = ysize + win->ypvmin;
embeddedartists 0:5e5e9ec91fc8 64
embeddedartists 0:5e5e9ec91fc8 65 /* Move image to window pixel by pixel */
embeddedartists 0:5e5e9ec91fc8 66 while ((y <= win->ypvmax) && (y < ysize)) {
embeddedartists 0:5e5e9ec91fc8 67 /* Set physical frame buffer address */
embeddedartists 0:5e5e9ec91fc8 68 x = win->xpvmin;
embeddedartists 0:5e5e9ec91fc8 69
embeddedartists 0:5e5e9ec91fc8 70 /* Render a single line */
embeddedartists 0:5e5e9ec91fc8 71 while ((x <= win->xpvmax) && (x < xsize)) {
embeddedartists 0:5e5e9ec91fc8 72 swim_put_pixel_physical(win, x, y, *image);
embeddedartists 0:5e5e9ec91fc8 73 image++;
embeddedartists 0:5e5e9ec91fc8 74 x++;
embeddedartists 0:5e5e9ec91fc8 75 }
embeddedartists 0:5e5e9ec91fc8 76
embeddedartists 0:5e5e9ec91fc8 77 /* Adjust to end of line if the image was clipped */
embeddedartists 0:5e5e9ec91fc8 78 image = image + (xsize - x);
embeddedartists 0:5e5e9ec91fc8 79
embeddedartists 0:5e5e9ec91fc8 80 y++;
embeddedartists 0:5e5e9ec91fc8 81 }
embeddedartists 0:5e5e9ec91fc8 82 }
embeddedartists 0:5e5e9ec91fc8 83
embeddedartists 0:5e5e9ec91fc8 84 /* Puts a raw image into a window at a specific position*/
embeddedartists 0:5e5e9ec91fc8 85 void swim_put_image_xy(SWIM_WINDOW_T *win,
embeddedartists 0:5e5e9ec91fc8 86 const COLOR_T *image,
embeddedartists 0:5e5e9ec91fc8 87 int32_t xsize,
embeddedartists 0:5e5e9ec91fc8 88 int32_t ysize,
embeddedartists 0:5e5e9ec91fc8 89 int32_t x1,
embeddedartists 0:5e5e9ec91fc8 90 int32_t y1)
embeddedartists 0:5e5e9ec91fc8 91 {
embeddedartists 0:5e5e9ec91fc8 92 int32_t x, y;
embeddedartists 0:5e5e9ec91fc8 93
embeddedartists 0:5e5e9ec91fc8 94 /* Unknown values of rtype will do no rotation */
embeddedartists 0:5e5e9ec91fc8 95 y = win->ypvmin + y1;
embeddedartists 0:5e5e9ec91fc8 96
embeddedartists 0:5e5e9ec91fc8 97 xsize = xsize + win->xpvmin + x1;
embeddedartists 0:5e5e9ec91fc8 98 ysize = ysize + win->ypvmin + y1;
embeddedartists 0:5e5e9ec91fc8 99
embeddedartists 0:5e5e9ec91fc8 100 /* Move image to window pixel by pixel */
embeddedartists 0:5e5e9ec91fc8 101 while ((y <= win->ypvmax) && (y < ysize)) {
embeddedartists 0:5e5e9ec91fc8 102 /* Set physical frame buffer address */
embeddedartists 0:5e5e9ec91fc8 103 x = win->xpvmin + x1;
embeddedartists 0:5e5e9ec91fc8 104
embeddedartists 0:5e5e9ec91fc8 105 /* Render a single line */
embeddedartists 0:5e5e9ec91fc8 106 while ((x <= win->xpvmax) && (x < xsize)) {
embeddedartists 0:5e5e9ec91fc8 107 swim_put_pixel_physical(win, x, y, *image);
embeddedartists 0:5e5e9ec91fc8 108 image++;
embeddedartists 0:5e5e9ec91fc8 109 x++;
embeddedartists 0:5e5e9ec91fc8 110 }
embeddedartists 0:5e5e9ec91fc8 111
embeddedartists 0:5e5e9ec91fc8 112 /* Adjust to end of line if the image was clipped */
embeddedartists 0:5e5e9ec91fc8 113 image = image + (xsize - x);
embeddedartists 0:5e5e9ec91fc8 114
embeddedartists 0:5e5e9ec91fc8 115 y++;
embeddedartists 0:5e5e9ec91fc8 116 }
embeddedartists 0:5e5e9ec91fc8 117 }
embeddedartists 0:5e5e9ec91fc8 118
embeddedartists 0:5e5e9ec91fc8 119 /* Puts a raw image into a window at a specific position, skipping all transparent pixels */
embeddedartists 0:5e5e9ec91fc8 120 void swim_put_transparent_image_xy(SWIM_WINDOW_T *win,
embeddedartists 0:5e5e9ec91fc8 121 const COLOR_T *image,
embeddedartists 0:5e5e9ec91fc8 122 int32_t xsize,
embeddedartists 0:5e5e9ec91fc8 123 int32_t ysize,
embeddedartists 0:5e5e9ec91fc8 124 int32_t x1,
embeddedartists 0:5e5e9ec91fc8 125 int32_t y1,
embeddedartists 0:5e5e9ec91fc8 126 COLOR_T tColor)
embeddedartists 0:5e5e9ec91fc8 127 {
embeddedartists 0:5e5e9ec91fc8 128 int32_t x, y;
embeddedartists 0:5e5e9ec91fc8 129
embeddedartists 0:5e5e9ec91fc8 130 /* Unknown values of rtype will do no rotation */
embeddedartists 0:5e5e9ec91fc8 131 y = win->ypvmin + y1;
embeddedartists 0:5e5e9ec91fc8 132
embeddedartists 0:5e5e9ec91fc8 133 xsize = xsize + win->xpvmin + x1;
embeddedartists 0:5e5e9ec91fc8 134 ysize = ysize + win->ypvmin + y1;
embeddedartists 0:5e5e9ec91fc8 135
embeddedartists 0:5e5e9ec91fc8 136 /* Move image to window pixel by pixel */
embeddedartists 0:5e5e9ec91fc8 137 while ((y <= win->ypvmax) && (y < ysize)) {
embeddedartists 0:5e5e9ec91fc8 138 /* Set physical frame buffer address */
embeddedartists 0:5e5e9ec91fc8 139 x = win->xpvmin + x1;
embeddedartists 0:5e5e9ec91fc8 140
embeddedartists 0:5e5e9ec91fc8 141 /* Render a single line */
embeddedartists 0:5e5e9ec91fc8 142 while ((x <= win->xpvmax) && (x < xsize)) {
embeddedartists 0:5e5e9ec91fc8 143 if (*image != tColor) {
embeddedartists 0:5e5e9ec91fc8 144 swim_put_pixel_physical(win, x, y, *image);
embeddedartists 0:5e5e9ec91fc8 145 }
embeddedartists 0:5e5e9ec91fc8 146 image++;
embeddedartists 0:5e5e9ec91fc8 147 x++;
embeddedartists 0:5e5e9ec91fc8 148 }
embeddedartists 0:5e5e9ec91fc8 149
embeddedartists 0:5e5e9ec91fc8 150 /* Adjust to end of line if the image was clipped */
embeddedartists 0:5e5e9ec91fc8 151 image = image + (xsize - x);
embeddedartists 0:5e5e9ec91fc8 152
embeddedartists 0:5e5e9ec91fc8 153 y++;
embeddedartists 0:5e5e9ec91fc8 154 }
embeddedartists 0:5e5e9ec91fc8 155 }
embeddedartists 0:5e5e9ec91fc8 156
embeddedartists 0:5e5e9ec91fc8 157 /* Puts a raw image into a window inverted */
embeddedartists 0:5e5e9ec91fc8 158 void swim_put_invert_image(SWIM_WINDOW_T *win,
embeddedartists 0:5e5e9ec91fc8 159 const COLOR_T *image,
embeddedartists 0:5e5e9ec91fc8 160 int32_t xsize,
embeddedartists 0:5e5e9ec91fc8 161 int32_t ysize)
embeddedartists 0:5e5e9ec91fc8 162 {
embeddedartists 0:5e5e9ec91fc8 163 int32_t x, y, xr, yr;
embeddedartists 0:5e5e9ec91fc8 164
embeddedartists 0:5e5e9ec91fc8 165 y = win->ypvmin;
embeddedartists 0:5e5e9ec91fc8 166 yr = ysize - 1;
embeddedartists 0:5e5e9ec91fc8 167
embeddedartists 0:5e5e9ec91fc8 168 /* Move image to window pixel by pixel */
embeddedartists 0:5e5e9ec91fc8 169 while ((y <= win->ypvmax) && (yr >= 0)) {
embeddedartists 0:5e5e9ec91fc8 170 /* Set physical frame buffer address */
embeddedartists 0:5e5e9ec91fc8 171 x = win->xpvmin;
embeddedartists 0:5e5e9ec91fc8 172 xr = xsize - 1;
embeddedartists 0:5e5e9ec91fc8 173
embeddedartists 0:5e5e9ec91fc8 174 /* Render a single line */
embeddedartists 0:5e5e9ec91fc8 175 while ((x <= win->xpvmax) && (xr >= 0)) {
embeddedartists 0:5e5e9ec91fc8 176 swim_put_pixel_physical(win, x, y, image[xr + yr * xsize] );
embeddedartists 0:5e5e9ec91fc8 177 x++;
embeddedartists 0:5e5e9ec91fc8 178 xr--;
embeddedartists 0:5e5e9ec91fc8 179 }
embeddedartists 0:5e5e9ec91fc8 180
embeddedartists 0:5e5e9ec91fc8 181 y++;
embeddedartists 0:5e5e9ec91fc8 182 yr--;
embeddedartists 0:5e5e9ec91fc8 183 }
embeddedartists 0:5e5e9ec91fc8 184 }
embeddedartists 0:5e5e9ec91fc8 185
embeddedartists 0:5e5e9ec91fc8 186 /* Puts a raw image into a window rotated left */
embeddedartists 0:5e5e9ec91fc8 187 void swim_put_left_image(SWIM_WINDOW_T *win,
embeddedartists 0:5e5e9ec91fc8 188 const COLOR_T *image,
embeddedartists 0:5e5e9ec91fc8 189 int32_t xsize,
embeddedartists 0:5e5e9ec91fc8 190 int32_t ysize)
embeddedartists 0:5e5e9ec91fc8 191 {
embeddedartists 0:5e5e9ec91fc8 192 int32_t x, y, xr, yr;
embeddedartists 0:5e5e9ec91fc8 193
embeddedartists 0:5e5e9ec91fc8 194 x = win->xpvmin;
embeddedartists 0:5e5e9ec91fc8 195 yr = ysize - 1;
embeddedartists 0:5e5e9ec91fc8 196
embeddedartists 0:5e5e9ec91fc8 197 /* Move image to window pixel by pixel */
embeddedartists 0:5e5e9ec91fc8 198 while ((x <= win->xpvmax) && (yr >= 0)) {
embeddedartists 0:5e5e9ec91fc8 199 /* Set physical frame buffer address to start drawing at
embeddedartists 0:5e5e9ec91fc8 200 bottom */
embeddedartists 0:5e5e9ec91fc8 201 y = win->ypvmin;
embeddedartists 0:5e5e9ec91fc8 202 xr = 0;
embeddedartists 0:5e5e9ec91fc8 203
embeddedartists 0:5e5e9ec91fc8 204 /* Render a single line */
embeddedartists 0:5e5e9ec91fc8 205 while ((y <= win->ypvmax) && (xr < xsize)) {
embeddedartists 0:5e5e9ec91fc8 206 /* Go to next line (y) */
embeddedartists 0:5e5e9ec91fc8 207 swim_put_pixel_physical(win, x, y,
embeddedartists 0:5e5e9ec91fc8 208 image[(xsize - xr - 1) + (ysize - yr - 1) * xsize]);
embeddedartists 0:5e5e9ec91fc8 209
embeddedartists 0:5e5e9ec91fc8 210 /* Update picture to next x coordinate */
embeddedartists 0:5e5e9ec91fc8 211 y++;
embeddedartists 0:5e5e9ec91fc8 212 xr++;
embeddedartists 0:5e5e9ec91fc8 213 }
embeddedartists 0:5e5e9ec91fc8 214
embeddedartists 0:5e5e9ec91fc8 215 x++;
embeddedartists 0:5e5e9ec91fc8 216 yr--;
embeddedartists 0:5e5e9ec91fc8 217 }
embeddedartists 0:5e5e9ec91fc8 218 }
embeddedartists 0:5e5e9ec91fc8 219
embeddedartists 0:5e5e9ec91fc8 220 /* Puts a raw image into a window rotated right */
embeddedartists 0:5e5e9ec91fc8 221 void swim_put_right_image(SWIM_WINDOW_T *win,
embeddedartists 0:5e5e9ec91fc8 222 const COLOR_T *image,
embeddedartists 0:5e5e9ec91fc8 223 int32_t xsize,
embeddedartists 0:5e5e9ec91fc8 224 int32_t ysize)
embeddedartists 0:5e5e9ec91fc8 225 {
embeddedartists 0:5e5e9ec91fc8 226 int32_t x, y, xr, yr;
embeddedartists 0:5e5e9ec91fc8 227
embeddedartists 0:5e5e9ec91fc8 228 x = win->xpvmin;
embeddedartists 0:5e5e9ec91fc8 229 yr = ysize - 1;
embeddedartists 0:5e5e9ec91fc8 230
embeddedartists 0:5e5e9ec91fc8 231 /* Move image to window pixel by pixel */
embeddedartists 0:5e5e9ec91fc8 232 while ((x <= win->xpvmax) && (yr >= 0)) {
embeddedartists 0:5e5e9ec91fc8 233 /* Set physical frame buffer address to start drawing at bottom */
embeddedartists 0:5e5e9ec91fc8 234 y = win->ypvmin;
embeddedartists 0:5e5e9ec91fc8 235 xr = 0;
embeddedartists 0:5e5e9ec91fc8 236
embeddedartists 0:5e5e9ec91fc8 237 /* Render a single line */
embeddedartists 0:5e5e9ec91fc8 238 while ((y <= win->ypvmax) && (xr < xsize)) {
embeddedartists 0:5e5e9ec91fc8 239 /* Go to next line (y) */
embeddedartists 0:5e5e9ec91fc8 240 swim_put_pixel_physical(win, x, y, image[xr + yr * xsize]);
embeddedartists 0:5e5e9ec91fc8 241
embeddedartists 0:5e5e9ec91fc8 242 /* Update picture to next x coordinate */
embeddedartists 0:5e5e9ec91fc8 243 y++;
embeddedartists 0:5e5e9ec91fc8 244 xr++;
embeddedartists 0:5e5e9ec91fc8 245 }
embeddedartists 0:5e5e9ec91fc8 246
embeddedartists 0:5e5e9ec91fc8 247 x++;
embeddedartists 0:5e5e9ec91fc8 248 yr--;
embeddedartists 0:5e5e9ec91fc8 249 }
embeddedartists 0:5e5e9ec91fc8 250 }
embeddedartists 0:5e5e9ec91fc8 251
embeddedartists 0:5e5e9ec91fc8 252 /* Puts and scales a raw image into a window */
embeddedartists 0:5e5e9ec91fc8 253 void swim_put_scale_image(SWIM_WINDOW_T *win,
embeddedartists 0:5e5e9ec91fc8 254 const COLOR_T *image,
embeddedartists 0:5e5e9ec91fc8 255 int32_t xsize,
embeddedartists 0:5e5e9ec91fc8 256 int32_t ysize)
embeddedartists 0:5e5e9ec91fc8 257 {
embeddedartists 0:5e5e9ec91fc8 258 int32_t xsc, ysc;
embeddedartists 0:5e5e9ec91fc8 259 int32_t x, y;
embeddedartists 0:5e5e9ec91fc8 260
embeddedartists 0:5e5e9ec91fc8 261 /* Top of window */
embeddedartists 0:5e5e9ec91fc8 262 y = win->ypvmin;
embeddedartists 0:5e5e9ec91fc8 263
embeddedartists 0:5e5e9ec91fc8 264 /* Rescale image into window */
embeddedartists 0:5e5e9ec91fc8 265 while (y <= win->ypvmax) {
embeddedartists 0:5e5e9ec91fc8 266 x = win->xpvmin;
embeddedartists 0:5e5e9ec91fc8 267
embeddedartists 0:5e5e9ec91fc8 268 /* Scale he display size to the image size */
embeddedartists 0:5e5e9ec91fc8 269 ysc = ((ysize - 1) * (y - win->ypvmin)) / win->yvsize;
embeddedartists 0:5e5e9ec91fc8 270
embeddedartists 0:5e5e9ec91fc8 271 /* Render a single line */
embeddedartists 0:5e5e9ec91fc8 272 while (x <= win->xpvmax) {
embeddedartists 0:5e5e9ec91fc8 273 /* Get x pixel in image */
embeddedartists 0:5e5e9ec91fc8 274 xsc = ((xsize - 1) * (x - win->xpvmin)) / win->xvsize;
embeddedartists 0:5e5e9ec91fc8 275 swim_put_pixel_physical(win, x, y, image[xsc + ysc * xsize] );
embeddedartists 0:5e5e9ec91fc8 276 x++;
embeddedartists 0:5e5e9ec91fc8 277 }
embeddedartists 0:5e5e9ec91fc8 278
embeddedartists 0:5e5e9ec91fc8 279 y++;
embeddedartists 0:5e5e9ec91fc8 280 }
embeddedartists 0:5e5e9ec91fc8 281 }
embeddedartists 0:5e5e9ec91fc8 282
embeddedartists 0:5e5e9ec91fc8 283 /* Puts and scales a raw image into a window inverted */
embeddedartists 0:5e5e9ec91fc8 284 void swim_put_scale_invert_image(SWIM_WINDOW_T *win,
embeddedartists 0:5e5e9ec91fc8 285 const COLOR_T *image,
embeddedartists 0:5e5e9ec91fc8 286 int32_t xsize,
embeddedartists 0:5e5e9ec91fc8 287 int32_t ysize)
embeddedartists 0:5e5e9ec91fc8 288 {
embeddedartists 0:5e5e9ec91fc8 289 int32_t xsc, ysc;
embeddedartists 0:5e5e9ec91fc8 290 int32_t x, y;
embeddedartists 0:5e5e9ec91fc8 291
embeddedartists 0:5e5e9ec91fc8 292 /* Top of window */
embeddedartists 0:5e5e9ec91fc8 293 y = win->ypvmin;
embeddedartists 0:5e5e9ec91fc8 294
embeddedartists 0:5e5e9ec91fc8 295 /* Rescale image into window */
embeddedartists 0:5e5e9ec91fc8 296 while (y <= win->ypvmax) {
embeddedartists 0:5e5e9ec91fc8 297 x = win->xpvmin;
embeddedartists 0:5e5e9ec91fc8 298
embeddedartists 0:5e5e9ec91fc8 299 /* Scale he display size to the image size */
embeddedartists 0:5e5e9ec91fc8 300 ysc = ((ysize - 1) * (y - win->ypvmin)) / win->yvsize;
embeddedartists 0:5e5e9ec91fc8 301
embeddedartists 0:5e5e9ec91fc8 302 /* Render a single line */
embeddedartists 0:5e5e9ec91fc8 303 while (x <= win->xpvmax) {
embeddedartists 0:5e5e9ec91fc8 304 /* Get x pixel in image */
embeddedartists 0:5e5e9ec91fc8 305 xsc = ((xsize - 1) * (x - win->xpvmin)) / win->xvsize;
embeddedartists 0:5e5e9ec91fc8 306 swim_put_pixel_physical(win, x, y,
embeddedartists 0:5e5e9ec91fc8 307 image[(xsize - 1 - xsc) + (ysize - 1 - ysc) * xsize]);
embeddedartists 0:5e5e9ec91fc8 308 x++;
embeddedartists 0:5e5e9ec91fc8 309 }
embeddedartists 0:5e5e9ec91fc8 310
embeddedartists 0:5e5e9ec91fc8 311 y++;
embeddedartists 0:5e5e9ec91fc8 312 }
embeddedartists 0:5e5e9ec91fc8 313 }
embeddedartists 0:5e5e9ec91fc8 314
embeddedartists 0:5e5e9ec91fc8 315 /* Puts and scales a raw image into a window rotated left */
embeddedartists 0:5e5e9ec91fc8 316 void swim_put_scale_left_image(SWIM_WINDOW_T *win,
embeddedartists 0:5e5e9ec91fc8 317 const COLOR_T *image,
embeddedartists 0:5e5e9ec91fc8 318 int32_t xsize,
embeddedartists 0:5e5e9ec91fc8 319 int32_t ysize)
embeddedartists 0:5e5e9ec91fc8 320 {
embeddedartists 0:5e5e9ec91fc8 321 int32_t xsc, ysc;
embeddedartists 0:5e5e9ec91fc8 322 int32_t x, y;
embeddedartists 0:5e5e9ec91fc8 323
embeddedartists 0:5e5e9ec91fc8 324 /* Top of window */
embeddedartists 0:5e5e9ec91fc8 325 y = win->ypvmin;
embeddedartists 0:5e5e9ec91fc8 326
embeddedartists 0:5e5e9ec91fc8 327 /* Rescale image into window */
embeddedartists 0:5e5e9ec91fc8 328 while (y <= win->ypvmax) {
embeddedartists 0:5e5e9ec91fc8 329 x = win->xpvmin;
embeddedartists 0:5e5e9ec91fc8 330
embeddedartists 0:5e5e9ec91fc8 331 /* Scale y coords of picture into x axis */
embeddedartists 0:5e5e9ec91fc8 332 ysc = ((xsize - 1) * (win->ypvmax - y)) / win->yvsize;
embeddedartists 0:5e5e9ec91fc8 333
embeddedartists 0:5e5e9ec91fc8 334 /* Render a single horizontal line with 'y' data */
embeddedartists 0:5e5e9ec91fc8 335 while (x <= win->xpvmax) {
embeddedartists 0:5e5e9ec91fc8 336 /* Get x pixel in image */
embeddedartists 0:5e5e9ec91fc8 337 xsc = ((ysize - 1) * (x - win->xpvmin)) / win->xvsize;
embeddedartists 0:5e5e9ec91fc8 338 swim_put_pixel_physical(win, x, y, image[ysc + xsc * xsize] );
embeddedartists 0:5e5e9ec91fc8 339 x++;
embeddedartists 0:5e5e9ec91fc8 340 }
embeddedartists 0:5e5e9ec91fc8 341
embeddedartists 0:5e5e9ec91fc8 342 y++;
embeddedartists 0:5e5e9ec91fc8 343 }
embeddedartists 0:5e5e9ec91fc8 344 }
embeddedartists 0:5e5e9ec91fc8 345
embeddedartists 0:5e5e9ec91fc8 346 /* Puts and scales a raw image into a window rotated right */
embeddedartists 0:5e5e9ec91fc8 347 void swim_put_scale_right_image(SWIM_WINDOW_T *win,
embeddedartists 0:5e5e9ec91fc8 348 const COLOR_T *image,
embeddedartists 0:5e5e9ec91fc8 349 int32_t xsize,
embeddedartists 0:5e5e9ec91fc8 350 int32_t ysize)
embeddedartists 0:5e5e9ec91fc8 351 {
embeddedartists 0:5e5e9ec91fc8 352 int32_t xsc, ysc;
embeddedartists 0:5e5e9ec91fc8 353 int32_t x, y;
embeddedartists 0:5e5e9ec91fc8 354
embeddedartists 0:5e5e9ec91fc8 355 /* Top of window */
embeddedartists 0:5e5e9ec91fc8 356 y = win->ypvmin;
embeddedartists 0:5e5e9ec91fc8 357
embeddedartists 0:5e5e9ec91fc8 358 /* Rescale image into window */
embeddedartists 0:5e5e9ec91fc8 359 while (y <= win->ypvmax) {
embeddedartists 0:5e5e9ec91fc8 360 x = win->xpvmin;
embeddedartists 0:5e5e9ec91fc8 361
embeddedartists 0:5e5e9ec91fc8 362 /* Scale y coords of picture into x axis */
embeddedartists 0:5e5e9ec91fc8 363 ysc = ((xsize - 1) * (y - win->ypvmin)) / win->yvsize;
embeddedartists 0:5e5e9ec91fc8 364
embeddedartists 0:5e5e9ec91fc8 365 /* Render a single horizontal line with 'y' data */
embeddedartists 0:5e5e9ec91fc8 366 while (x <= win->xpvmax) {
embeddedartists 0:5e5e9ec91fc8 367 /* Get x pixel in image */
embeddedartists 0:5e5e9ec91fc8 368 xsc = ((ysize - 1) * (win->xpvmax - x)) / win->xvsize;
embeddedartists 0:5e5e9ec91fc8 369 swim_put_pixel_physical(win, x, y, image[ysc + xsc * xsize]);
embeddedartists 0:5e5e9ec91fc8 370 x++;
embeddedartists 0:5e5e9ec91fc8 371 }
embeddedartists 0:5e5e9ec91fc8 372
embeddedartists 0:5e5e9ec91fc8 373 y++;
embeddedartists 0:5e5e9ec91fc8 374 }
embeddedartists 0:5e5e9ec91fc8 375 }
embeddedartists 0:5e5e9ec91fc8 376
embeddedartists 0:5e5e9ec91fc8 377 /* SWIM image draw composite function */
embeddedartists 0:5e5e9ec91fc8 378 void swim_put_win_image(SWIM_WINDOW_T *win,
embeddedartists 0:5e5e9ec91fc8 379 const COLOR_T *image,
embeddedartists 0:5e5e9ec91fc8 380 int32_t xsize,
embeddedartists 0:5e5e9ec91fc8 381 int32_t ysize,
embeddedartists 0:5e5e9ec91fc8 382 int32_t scale,
embeddedartists 0:5e5e9ec91fc8 383 SWIM_ROTATION_T rtype)
embeddedartists 0:5e5e9ec91fc8 384 {
embeddedartists 0:5e5e9ec91fc8 385 switch (rtype) {
embeddedartists 0:5e5e9ec91fc8 386 case INVERT:
embeddedartists 0:5e5e9ec91fc8 387 if (scale != 0) {
embeddedartists 0:5e5e9ec91fc8 388 swim_put_scale_invert_image(win, image, xsize, ysize);
embeddedartists 0:5e5e9ec91fc8 389 }
embeddedartists 0:5e5e9ec91fc8 390 else {
embeddedartists 0:5e5e9ec91fc8 391 swim_put_invert_image(win, image, xsize, ysize);
embeddedartists 0:5e5e9ec91fc8 392 }
embeddedartists 0:5e5e9ec91fc8 393 break;
embeddedartists 0:5e5e9ec91fc8 394
embeddedartists 0:5e5e9ec91fc8 395 case LEFT:
embeddedartists 0:5e5e9ec91fc8 396 if (scale != 0) {
embeddedartists 0:5e5e9ec91fc8 397 swim_put_scale_left_image(win, image, xsize, ysize);
embeddedartists 0:5e5e9ec91fc8 398 }
embeddedartists 0:5e5e9ec91fc8 399 else {
embeddedartists 0:5e5e9ec91fc8 400 swim_put_left_image(win, image, xsize, ysize);
embeddedartists 0:5e5e9ec91fc8 401 }
embeddedartists 0:5e5e9ec91fc8 402 break;
embeddedartists 0:5e5e9ec91fc8 403
embeddedartists 0:5e5e9ec91fc8 404 case RIGHT:
embeddedartists 0:5e5e9ec91fc8 405 if (scale != 0) {
embeddedartists 0:5e5e9ec91fc8 406 swim_put_scale_right_image(win, image, xsize, ysize);
embeddedartists 0:5e5e9ec91fc8 407 }
embeddedartists 0:5e5e9ec91fc8 408 else {
embeddedartists 0:5e5e9ec91fc8 409 swim_put_right_image(win, image, xsize, ysize);
embeddedartists 0:5e5e9ec91fc8 410 }
embeddedartists 0:5e5e9ec91fc8 411 break;
embeddedartists 0:5e5e9ec91fc8 412
embeddedartists 0:5e5e9ec91fc8 413 case NOROTATION:
embeddedartists 0:5e5e9ec91fc8 414 default:
embeddedartists 0:5e5e9ec91fc8 415 if (scale != 0) {
embeddedartists 0:5e5e9ec91fc8 416 swim_put_scale_image(win, image, xsize, ysize);
embeddedartists 0:5e5e9ec91fc8 417 }
embeddedartists 0:5e5e9ec91fc8 418 else {
embeddedartists 0:5e5e9ec91fc8 419 swim_put_image(win, image, xsize, ysize);
embeddedartists 0:5e5e9ec91fc8 420 }
embeddedartists 0:5e5e9ec91fc8 421 break;
embeddedartists 0:5e5e9ec91fc8 422 }
embeddedartists 0:5e5e9ec91fc8 423 }
embeddedartists 0:5e5e9ec91fc8 424