1Name 2 3 HP_image_transform 4 5Name Strings 6 7 GL_HP_image_transform 8 9Version 10 11 $Date: 1996/04/22 23:23:13 $ $Revision: 1.1 $ 12 13Number 14 15 66 16 17Dependencies 18 19 EXT_texture is required 20 EXT_convolution affects the definition of this extension 21 SGI_color_table is required 22 23Overview 24 25 This extension provides support for scaling, rotation, and translation 26 of two-dimensional pixel rectangles at a fixed location in the pixel 27 transfer process. The 2D image transformation attributes are specified 28 as individual values so that that implementations may easily detect 29 scaling and rotation values that lend themselves to optimization. 2D 30 image transformation occurs immediately after the post-convolution color 31 table stage of the pixel pipeline. This extension also defines a color 32 table that is applied immediately after the image transformation operation. 33 34New Procedures and Functions 35 36 void ImageTransformParameteriHP(enum target, 37 enum pname, 38 const int param) 39 40 void ImageTransformParameterfHP(enum target, 41 enum pname, 42 const float param) 43 44 void ImageTransformParameterivHP(enum target, 45 enum pname, 46 const int* params) 47 48 void ImageTransformParameterfvHP(enum target, 49 enum pname, 50 const float* params) 51 52 These routines are used to set image transformation attributes. 53 The only allowable value for <target> at this time is 54 IMAGE_TRANSFORM_2D_HP. Allowable values for <pname> include: 55 IMAGE_SCALE_X_HP, IMAGE_SCALE_Y_HP, IMAGE_ROTATE_ANGLE_HP, 56 IMAGE_ROTATE_ORIGIN_X_HP, IMAGE_ROTATE_ORIGIN_Y_HP, 57 IMAGE_TRANSLATE_X_HP, IMAGE_TRANSLATE_Y_HP, IMAGE_MAG_FILTER_HP, 58 IMAGE_MIN_FILTER_HP, and IMAGE_CUBIC_WEIGHT_HP. 59 60 void GetImageTransformParameterivHP(enum target, 61 enum pname, 62 const int* params) 63 64 void GetImageTransformParameterfvHP(enum target, 65 enum pname, 66 const float* params) 67 68 These routines are used to query image transformation attributes. 69 The only allowable value for <target> at this time is 70 IMAGE_TRANSFORM_2D_HP. Allowable values for <pname> include: 71 IMAGE_SCALE_X_HP, IMAGE_SCALE_Y_HP, IMAGE_ROTATE_ANGLE_HP, 72 IMAGE_ROTATE_ORIGIN_X_HP, IMAGE_ROTATE_ORIGIN_Y_HP, 73 IMAGE_TRANSLATE_X_HP, IMAGE_TRANSLATE_Y_HP, IMAGE_MAG_FILTER_HP, 74 IMAGE_MIN_FILTER_HP, and IMAGE_CUBIC_WEIGHT_HP. 75 76New Tokens 77 78 Accepted by the <pname> parameter of ImageTransformParameteri, 79 ImageTransformParameterf, ImageTransformParameteriv, 80 ImageTransformParameterfv, GetImageTransformParameteriv and 81 GetImageTransformParameterfv: 82 83 IMAGE_SCALE_X_HP 84 IMAGE_SCALE_Y_HP 85 IMAGE_TRANSLATE_X_HP 86 IMAGE_TRANSLATE_Y_HP 87 IMAGE_ROTATE_ANGLE_HP 88 IMAGE_ROTATE_ORIGIN_X_HP 89 IMAGE_ROTATE_ORIGIN_Y_HP 90 IMAGE_MAG_FILTER_HP 91 IMAGE_MIN_FILTER_HP 92 IMAGE_CUBIC_WEIGHT_HP 93 94 Accepted by the <params> parameter of ImageTransformParameteriHP, 95 ImageTransformParameterfHP, ImageTransformParameterivHP, and 96 ImageTransformParameterfvHP when <pname> is IMAGE_MAG_FILTER_HP 97 or IMAGE_MIN_FILTER_HP: 98 99 CUBIC_HP 100 101 Accepted by the <params> parameter of ImageTransformParameteriHP, 102 ImageTransformParameterfHP, ImageTransformParameterivHP, and 103 ImageTransformParameterfvHP when <pname> is IMAGE_MIN_FILTER_HP: 104 105 AVERAGE_HP 106 107 Accepted by the <cap> parameter of Enable, Disable, and IsEnabled, 108 and by the <target> parameter of ImageTransformParameterivHP, 109 ImageTransformParameterfvHP, GetImageTransformParameterivHP, 110 and GetImageTransformParameterfvHP: 111 112 IMAGE_TRANSFORM_2D_HP 113 114 Accepted by the <cap> parameter of Enable, Disable, and IsEnabled, and 115 by the <target> parameter of ColorTableSGI, ColorTableParameterivSGI, 116 ColorTableParameterfvSGI, GetColorTableSGI, GetColorTableParameterivSGI, 117 and GetColorTableParameterfvSGI: 118 119 POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 120 121 Accepted by the <target> parameter of ColorTableSGI, 122 GetColorTableParameterivSGI, and GetColorTableParameterfvSGI: 123 124 PROXY_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 125 126Additions to Chapter 2 of the 1.0 Specification (OpenGL Operation) 127 128 None 129 130Additions to Chapter 3 of the 1.0 Specification (Rasterization) 131 132 The specification of two-dimensional image transformation operators 133 is added to the GL specification in Section 3.6.2, "Pixel Transfer 134 Modes." 2D image transformation operators are defined by calling 135 ImageTransformParameteriHP, ImageTransformParameterfHP, 136 ImageTransformParameterivHP, or ImageTransformParameterfvHP with 137 <target> set to IMAGE_TRANSFORM_2D_HP. Parameter values 138 IMAGE_SCALE_X_HP and IMAGE_SCALE_Y_HP establish the scaling factors. 139 IMAGE_TRANSLATE_X_HP and IMAGE_TRANSLATE_Y_HP set the translation 140 factors. IMAGE_ROTATE_ANGLE_HP sets the rotation angle to be 141 used, and IMAGE_ROTATE_ORIGIN_X_HP and IMAGE_ROTATE_ORIGIN_Y_HP specify 142 the point about which the image is to be scaled and rotated. If the 143 specified angle is positive, the rotation will be counterclockwise 144 about the specified rotation origin. If the specified angle is 145 negative, the rotation will be clockwise about the origin. All 146 of these parameters (scale, rotation, translation, rotation origin) 147 are specified in terms of the input image's coordinates. 148 IMAGE_MAG_FILTER_HP establishes the resampling technique that is to be 149 used after the other image transformation operators have been applied 150 if the image is deemed to have been magnified. IMAGE_MIN_FILTER_HP 151 defines the resampling technique that is to be applied if the image 152 is minified by the scaling factors. IMAGE_CUBIC_WEIGHT_HP defines 153 the cubic weighting coefficient that is to be used whenever the 154 resampling technique is set to CUBIC_HP. 155 156 The operations defined by the image transformation operation are 157 added to the GL specification in Section 3.6.3, "Rasterization of 158 Pixel Rectangles," immediately following the operations described in 159 the EXT_convolution extension and the post convolution color table 160 operation that is described in the SGI_color_table extension. Image 161 transformation is defined only for pixel rectangles that contain RGBA 162 components or depth components at this stage of the pixel processing 163 pipeline (color index values may have been converted to RGBA by a 164 previous stage). Image transformation is not applied to color index 165 or stencil index pixel data. 166 167 When enabled, the image transformation operation uses the current set 168 of image transformation parameters to compute a new window coordinate 169 for each incoming pixel. Although image transformation parameters 170 are specified separately, the scaling, rotation, and translation 171 operations are all applied simultaneously (as if the transformation 172 was encoded in a matrix and the resulting matrix was applied to each 173 incoming pixel coordinate). In the case of 2D image transformation, 174 if (Rx,Ry) specifies the rotation origin, the effect of applying the 175 2D image transformation operators can be defined as follows. First, 176 the image is translated by -Rx in the x direction and -Ry in the y 177 direction so that its rotation origin is at the origin of the 2D 178 coordinate system. Second, the x and y scaling factors are 179 applied, causing the image to be scaled as specified in x and y. 180 Third, the rotation angle is applied, causing the image to be rotated 181 about the origin by the specified angle. Next, the image is translated 182 by Rx in the x direction and Ry in the y direction. Finally, the 183 scaled and rotated image is translated by the specified translation 184 factors. Resampling occurs after the scaling/rotation/translation 185 operations have been applied. 186 187 The RGBA or depth value for each location is left unmodified by the image 188 transformation. Since multiple input pixels can be mapped into a single 189 output pixel (minification of input image), or since output pixels might 190 not have any input pixels mapped to them (magnification of input image), 191 some method of resampling is required. The resampling method to be 192 used when the image is magnified is specified by calling 193 ImageTransformParameteri, ImageTransformParameterf, 194 ImageTransformParameteriv, or ImageTransformParameterfv with <pname> 195 set to IMAGE_MAG_FILTER_HP and <params> set to NEAREST, LINEAR, or CUBIC_HP. 196 The resampling method to be used when the image is minified is specified 197 by calling ImageTransformParameteri, ImageTransformParameterf, 198 ImageTransformParameteriv, or ImageTransformParameterfv with <pname> 199 set to IMAGE_MIN_FILTER_HP and <params> set to NEAREST, LINEAR, CUBIC_HP, 200 or AVERAGE_HP. If the resampling method is NEAREST, each output pixel will 201 have the value of the input pixel whose transformed coordinate value is 202 nearest (in Manhattan distance). If the resampling method is LINEAR, each 203 output pixel will have a value that is the weighted average of the four input 204 pixels whose transformed coordinate values are nearest. 205 206 If the resampling method is CUBIC_HP, each output pixel will have a value 207 that is affected by the 16 input pixels whose transformed coordinate 208 values are nearest. The 16 input pixels will be used to perform a cubic 209 spline interpolation to determine the value of the output pixel. The 210 cubic weight factor is a floating point value that is applied to the 211 cubic interpolation in the manner described in "Digital Image Warping" 212 by George Wolberg (IEEE Computer Society Press, ISBN 0-8186-8944-7). 213 Visually pleasing cubic weighting values are typically in the 214 range [-1,0]. The values -1.0 and -0.5 are most commonly used. 215 For the purpose of performing bicubic interpolation along the outer 216 edge of the image, the outermost one pixel edge of the image is 217 duplicated prior to performing the interpolation along the edges. 218 219 If the resampling method is AVERAGE_HP, the values of all of the input 220 pixels that contribute to the final output pixel will be averaged to 221 determine the final output pixel value. 222 223 The operation of the POST_IMAGE_TRANSFORM_COLOR_TABLE is added to the GL 224 Specification in section 3.6.3, "Rasterization of Pixel Rectangles". 225 This color table behaves in the manner described in the SGI_color_table 226 extension, and it is located immediately after the image transformation 227 operation. This color table can be enabled or disabled separately from 228 the image transformation operation by calling Enable or Disable with 229 POST_IMAGE_TRANSFORM_COLOR_TABLE. It can be modified using the procedures 230 defined in the SGI_color_table extension. The proxy version of this table 231 can be set or queried by using a target value of 232 PROXY_POST_IMAGE_TRANSFORM_COLOR_TABLE. 233 234Additions to Chapter 4 of the 1.0 Specification (Per-Fragment Operations 235and the Frame Buffer) 236 237 The operation of image transformation during pixel copy and query 238 operations is identical to the operation during pixel drawing and 239 texture image definition. The image transformation operation occurs 240 immediately after the operations described by EXT_convolution and 241 the post-convolution color table described by SGI_color_table, which 242 follow section 4.3.2 (Reading Pixels) of the GL Specification. 243 244Additions to Chapter 5 of the 1.0 Specification (Special Functions) 245 246 GetImageTransformParameterivHP, and GetImageTransformParameterfvHP 247 are not included in display lists, but are instead executed immediately. 248 249Additions to Chapter 6 of the 1.0 Specification (State and State Requests) 250 251 Integer and floating point query functions GetImageTransformParameterivHP 252 and GetImageTransformParameterfvHP are provided. <target> must be 253 IMAGE_TRANSFORM_2D_HP. <pname> is one of IMAGE_SCALE_X_HP, 254 IMAGE_SCALE_Y_HP, IMAGE_TRANSLATE_X_HP, IMAGE_TRANSLATE_Y_HP, 255 IMAGE_ROTATE_ANGLE_HP, IMAGE_ROTATE_ORIGIN_X_HP, 256 IMAGE_ROTATE_ORIGIN_Y_HP, IMAGE_MAG_FILTER_HP, IMAGE_MIN_FILTER_HP, 257 or IMAGE_CUBIC_WEIGHT_HP. The value of the specified parameter is 258 returned in <params>. 259 260Additions to the GLX Specification 261 262 None 263 264Dependencies on EXT_texture 265 266 EXT_texture is required. This extension builds on the notion of 267 internal image format, which is defined by EXT_texture. 268 269Dependencies on EXT_convolution 270 271 None, except that image transformation follows the convolution 272 operation (and its scale and bias). If the post-convolution color 273 table is supported, the image transformation operation will occur 274 immediately after the post-convolution color table operation. If 275 convolution is not supported, the location with respect to all other 276 pixel operations remains the same. 277 278Dependencies on SGI_color_table 279 280 SGI_color_table is required. This extension builds on the notion of 281 color lookup tables at various locations in the pixel processing pipeline. 282 This extension adds another table to the list specified by SGI_color_table. 283 This new table can be manipulated using the procedures defined by 284 SGI_color_table. 285 286Errors 287 288 INVALID_ENUM is generated if ImageTransformParameteriHP, 289 ImageTransformParameterfHP, ImageTransformParameterivHP, 290 ImageTransformParameterfvHP, GetImageTransformParameterivHP, 291 or GetImageTransformParameterfvHP is called with <target> set to 292 a value other than IMAGE_TRANSFORM_2D_HP. 293 294 INVALID_ENUM is generated if GetImageTransformParameterivHP or 295 GetImageTransformParameterfvHP is called with <pname> set to 296 IMAGE_MAG_FILTER_HP and <params> is not one of NEAREST, LINEAR, 297 or CUBIC_HP. 298 299 INVALID_ENUM is generated if GetImageTransformParameterivHP or 300 GetImageTransformParameterfvHP is called with <pname> set to 301 IMAGE_MIN_FILTER_HP and <params> is not one of NEAREST, LINEAR, 302 CUBIC_HP, or AVERAGE_HP. 303 304 INVALID_VALUE is generated if ImageTransformParameteriHP, 305 ImageTransformParameterfHP, ImageTransformParameterivHP, or 306 ImageTransformParameterfvHP is called with <pname> set to 307 IMAGE_CUBIC_WEIGHT_HP and <params> is a value outside of 308 the range [0,1]. 309 310 INVALID_OPERATION is generated if ImageTransformParameteriHP, 311 ImageTransformParameterfHP, ImageTransformParameterivHP, 312 ImageTransformParameterfvHP, GetImageTransformParameterivHP, 313 or GetImageTransformParameterfvHP is called between execution of 314 Begin and the corresponding execution of End. 315 316New State 317 Initial 318 Get Value Get Command Type Value Attrib 319 --------- ----------- ---- ------- ------ 320 IMAGE_TRANSFORM_2D_HP IsEnabled B False pixel/enable 321 IMAGE_SCALE_X_HP GetImageTransformParameterf R 1 pixel 322 IMAGE_SCALE_Y_HP GetImageTransformParameterf R 1 pixel 323 IMAGE_TRANSLATE_X_HP GetImageTransformParameterf R 0 pixel 324 IMAGE_TRANSLATE_Y_HP GetImageTransformParameterf R 0 pixel 325 IMAGE_ROTATE_ANGLE_HP GetImageTransformParameterf R 0 pixel 326 IMAGE_ROTATE_ORIGIN_X_HP GetImageTransformParameterf R 0 pixel 327 IMAGE_ROTATE_ORIGIN_Y_HP GetImageTransformParameterf R 0 pixel 328 IMAGE_MAG_FILTER_HP GetImageTransformParameteri Z3 NEAREST pixel 329 IMAGE_MIN_FILTER_HP GetImageTransformParameteri Z4 NEAREST pixel 330 IMAGE_CUBIC_WEIGHT_HP GetImageTransformParameterf R -1 pixel 331 POST_IMAGE_TRANSFORM_COLOR_TABLE_HP IsEnabled B False pixel/enable 332 POST_IMAGE_TRANSFORM_COLOR_TABLE_HP GetColorTableHP 3 x I empty - 333 334New Implementation Dependent State 335 336 None 337 338Issues 339 340 What is the behavior of ReadPixels when the image transformation 341 is enabled? One suggestion is to assume that the specified width 342 and height of the region being read are used to define the size 343 of the 2D array in host memory in which the pixel values are to 344 be written. Any pixels that would be written outside of this region 345 would be clipped. Why would anyone want to rotate/scale during 346 a readback operation anyway? Another suggestion is that image 347 transformation is ignored during readback, but this makes it 348 different than the other pixel transfer operations. 349 350Notes 351 352 I originally wrote this extension to utilize an image transformation 353 matrix that worked the same way the other OpenGL matrices worked. 354 However, we found that we could not easily extract the rotation and 355 scaling information and use it to select optimized software routines 356 for special cases like integer zoom and 90 degree rotations. 357 Consequently, I've reverted back to specifying the image transformation 358 parameters individually and the image transformation operation 359 in a more rigid way. 360 361 I would rather have separate state setting calls for each of the 362 2D image transformation parameters. However, SGI's convolution, 363 color table, and histogram extension all use FooParameter{i,f}v calls 364 to set the state. I've mimicked their API for three reasons: 365 1. For consistency with those extensions 366 2. To maximize the likelihood of industry acceptance 367 of this extension 368 3. To allow for the possibility of 1D and 3D image 369 transforms at a future time. 370 371 I have not excluded the ability to scale, rotate, and translate 372 depth component values. I thought that image transformation might 373 be useful when the <format> was DEPTH_COMPONENT (i.e., reading or writing 374 depth buffer values). In this case, the "image" will have x and y values 375 that define the pixel locations, and depth (z) values instead of color 376 values. The depth values will end up being treated as a single channel 377 image. This capability might be necessary if you have a depth buffer 378 associated with an image that you want to remain registered as it is 379 stored in the frame buffer. 380