ilhplrotation.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. /*
  2. * CDE - Common Desktop Environment
  3. *
  4. * Copyright (c) 1993-2012, The Open Group. All rights reserved.
  5. *
  6. * These libraries and programs are free software; you can
  7. * redistribute them and/or modify them under the terms of the GNU
  8. * Lesser General Public License as published by the Free Software
  9. * Foundation; either version 2 of the License, or (at your option)
  10. * any later version.
  11. *
  12. * These libraries and programs are distributed in the hope that
  13. * they will be useful, but WITHOUT ANY WARRANTY; without even the
  14. * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  15. * PURPOSE. See the GNU Lesser General Public License for more
  16. * details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with these libraries and programs; if not, write
  20. * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
  21. * Floor, Boston, MA 02110-1301 USA
  22. */
  23. /* $XConsortium: ilhplrotation.h /main/3 1995/10/23 15:48:46 rswiston $ */
  24. /**---------------------------------------------------------------------
  25. ***
  26. *** (c)Copyright 1991 Hewlett-Packard Co.
  27. ***
  28. *** RESTRICTED RIGHTS LEGEND
  29. *** Use, duplication, or disclosure by the U.S. Government is subject to
  30. *** restrictions as set forth in sub-paragraph (c)(1)(ii) of the Rights in
  31. *** Technical Data and Computer Software clause in DFARS 252.227-7013.
  32. *** Hewlett-Packard Company
  33. *** 3000 Hanover Street
  34. *** Palo Alto, CA 94304 U.S.A.
  35. *** Rights for non-DOD U.S. Government Departments and Agencies are as set
  36. *** forth in FAR 52.227-19(c)(1,2).
  37. ***
  38. ***-------------------------------------------------------------------*/
  39. /*
  40. NOTE to ALL users:
  41. 1.See the last section of this file for an Example about how to use this
  42. library.
  43. NOTES to DOS/WINDOWS users only:
  44. 1.Define FAR_DATA_PTR, if you want to use 32bit data pointers instead of
  45. the 16bit ones. This is not necessary in Compact, Large, or Huge
  46. Memory Models.
  47. */
  48. #ifndef NeedFunctionPrototypes
  49. #if defined(FUNCPROTO) || defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)
  50. #define NeedFunctionPrototypes 1
  51. #else
  52. #define NeedFunctionPrototypes 0
  53. #endif /* __STDC__ */
  54. #endif /* NeedFunctionPrototypes */
  55. #ifdef FAR_DATA_PTR
  56. typedef unsigned char huge * DATA_IN_PTR;
  57. typedef unsigned char far * DATA_OUT_PTR;
  58. typedef unsigned char DATA_IN;
  59. typedef unsigned char DATA_OUT;
  60. #else
  61. typedef unsigned char * DATA_IN_PTR;
  62. typedef unsigned char * DATA_OUT_PTR;
  63. typedef unsigned char DATA_IN;
  64. typedef unsigned char DATA_OUT;
  65. #endif
  66. extern DATA_IN_PTR _il_Rotate_Image_Begin(
  67. #if NeedFunctionPrototypes
  68. short input_w, /* Input image width */
  69. short input_h, /* Input image height */
  70. short input_bytes, /* Input image bytes per pixel (1 or 3).
  71. 1 : gray scale image (8 bits / pixel).
  72. 3 : color image (24 bits / pixel). */
  73. short rotation_mode, /* 0 : subsampling (nearest pixel)
  74. !0 : bi-linear interpolation */
  75. float angle, /* Rotation Angle */
  76. unsigned char bg_red, /* background color */
  77. unsigned char bg_green, /* , if input_bytes == 1, */
  78. unsigned char bg_blue, /* background gray level = bg_red */
  79. short *output_w, /* Returned value for output image width*/
  80. short *output_h /* Returned val. for output image height*/
  81. #endif
  82. );
  83. /*
  84. * Must be called before any rotation can take place.
  85. *
  86. * Returns a pointer to the location where the image data of the first row
  87. * must be read into, or NULL if memory can not be allocated.
  88. */
  89. extern short _il_Rotate_Send(
  90. #if NeedFunctionPrototypes
  91. DATA_IN_PTR *input_data /* returned location for next input data row */
  92. #endif
  93. );
  94. /*
  95. * After reading the image data of the first row into the location returned by
  96. * IR_Rotate_Image_Begin, use this call to get the new location for the next
  97. * row's image data.
  98. *
  99. * Returns the number of output data rows ready to be retrieve by
  100. * IR_Rotate_Get_Row
  101. */
  102. extern void _il_Rotate_Get_Row(
  103. #if NeedFunctionPrototypes
  104. DATA_OUT_PTR row /* output data row */
  105. #endif
  106. );
  107. /*
  108. * Read next output data row into the user provided buffer 'row'.
  109. */
  110. extern void _il_Rotate_Image_End();
  111. /*
  112. * Must be called when done with rotation to free any memory created during
  113. * the rotation process.
  114. */
  115. /*
  116. * EXAMPLE:
  117. *
  118. * In order to use this rotation library, your software structure should
  119. * look similar to this:
  120. *
  121. * ...
  122. * short in_w, in_h, out_w, out_h, nrows;
  123. * DATA_IN_PTR data_in;
  124. * DATA_OUT_PTR buf;
  125. *
  126. * ...
  127. * data_in = IR_Rotate_Image_Begin(..., start rotation
  128. * &out_w, &out_h);
  129. * buf = (DATA_OUT_PTR) malloc(out_w*image_bytes); allocate output buffer
  130. *
  131. * for (i = 0; i < in_h; i++) { for each input image row
  132. * read_input_data(data_in); read in next data row
  133. * for (nrows = IR_Rotate_Send_Row(&data_in); get next location for
  134. * nrows > 0; --nrows) { data_in, and for each
  135. * output data row
  136. * IR_Rotate_Get_Row(buf); get output data
  137. * process_data(buf); process it
  138. * }; end inner for loop
  139. * }; end outer for loop
  140. * IR_Rotate_Image_End(); finish rotation
  141. * ...
  142. */