SDL_CreateCursor.3
上传用户:sun1608
上传日期:2007-02-02
资源大小:6116k
文件大小:3k
源码类别:

流媒体/Mpeg4/MP4

开发平台:

Visual C++

  1. .TH "SDL_CreateCursor" "3" "Tue 11 Sep 2001, 23:01" "SDL" "SDL API Reference" 
  2. .SH "NAME"
  3. SDL_CreateCursor- Creates a new mouse cursor&.
  4. .SH "SYNOPSIS"
  5. .PP
  6. fB#include "SDL&.h"
  7. .sp
  8. fBSDL_Cursor *fBSDL_CreateCursorfPfR(fBUint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_yfR);
  9. .SH "DESCRIPTION"
  10. .PP
  11. Create a cursor using the specified fBdatafR and fBmaskfR (in MSB format)&. The cursor width must be a multiple of 8 bits&.
  12. .PP
  13. The cursor is created in black and white according to the following: 
  14. .TP 20
  15. fBData / MaskfR
  16. fBResulting pixel on screenfR
  17. .TP 20
  18. 0 / 1
  19. White
  20. .TP 20
  21. 1 / 1
  22. Black
  23. .TP 20
  24. 0 / 0
  25. Transparent
  26. .TP 20
  27. 1 / 0
  28. Inverted color if possible, black if not&.
  29. .PP
  30. Cursors created with this function must be freed with fISDL_FreeCursorfR&.
  31. .SH "EXAMPLE"
  32. .PP
  33. .nf
  34. f(CW/* Stolen from the mailing list */
  35. /* Creates a new mouse cursor from an XPM */
  36. /* XPM */
  37. static const char *arrow[] = {
  38.   /* width height num_colors chars_per_pixel */
  39.   "    32    32        3            1",
  40.   /* colors */
  41.   "X c #000000",
  42.   "&. c #ffffff",
  43.   "  c None",
  44.   /* pixels */
  45.   "X                               ",
  46.   "XX                              ",
  47.   "X&.X                             ",
  48.   "X&.&.X                            ",
  49.   "X&.&.&.X                           ",
  50.   "X&.&.&.&.X                          ",
  51.   "X&.&.&.&.&.X                         ",
  52.   "X&.&.&.&.&.&.X                        ",
  53.   "X&.&.&.&.&.&.&.X                       ",
  54.   "X&.&.&.&.&.&.&.&.X                      ",
  55.   "X&.&.&.&.&.XXXXX                     ",
  56.   "X&.&.X&.&.X                         ",
  57.   "X&.X X&.&.X                        ",
  58.   "XX  X&.&.X                        ",
  59.   "X    X&.&.X                       ",
  60.   "     X&.&.X                       ",
  61.   "      X&.&.X                      ",
  62.   "      X&.&.X                      ",
  63.   "       XX                       ",
  64.   "                                ",
  65.   "                                ",
  66.   "                                ",
  67.   "                                ",
  68.   "                                ",
  69.   "                                ",
  70.   "                                ",
  71.   "                                ",
  72.   "                                ",
  73.   "                                ",
  74.   "                                ",
  75.   "                                ",
  76.   "                                ",
  77.   "0,0"
  78. };
  79. static SDL_Cursor *init_system_cursor(const char *image[])
  80. {
  81.   int i, row, col;
  82.   Uint8 data[4*32];
  83.   Uint8 mask[4*32];
  84.   int hot_x, hot_y;
  85.   i = -1;
  86.   for ( row=0; row<32; ++row ) {
  87.     for ( col=0; col<32; ++col ) {
  88.       if ( col % 8 ) {
  89.         data[i] <<= 1;
  90.         mask[i] <<= 1;
  91.       } else {
  92.         ++i;
  93.         data[i] = mask[i] = 0;
  94.       }
  95.       switch (image[4+row][col]) {
  96.         case &'X&':
  97.           data[i] |= 0x01;
  98.           k[i] |= 0x01;
  99.           break;
  100.         case &'&.&':
  101.           mask[i] |= 0x01;
  102.           break;
  103.         case &' &':
  104.           break;
  105.       }
  106.     }
  107.   }
  108.   sscanf(image[4+row], "%d,%d", &hot_x, &hot_y);
  109.   return SDL_CreateCursor(data, mask, 32, 32, hot_x, hot_y);
  110. }fR
  111. .fi
  112. .PP
  113. .SH "SEE ALSO"
  114. .PP
  115. fIfBSDL_FreeCursorfPfR, fIfBSDL_SetCursorfPfR, fIfBSDL_ShowCursorfPfR
  116. ..." created by instant / docbook-to-man, Tue 11 Sep 2001, 23:01