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