PageRenderTime 38ms CodeModel.GetById 16ms RepoModel.GetById 1ms app.codeStats 0ms

/src/CrBufFrP.c

#
C | 77 lines | 34 code | 7 blank | 36 comment | 6 complexity | d010f9b62fed14481197cc95997934d4 MD5 | raw file
  1. /*
  2. * Copyright (C) 1989-95 GROUPE BULL
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a copy
  5. * of this software and associated documentation files (the "Software"), to
  6. * deal in the Software without restriction, including without limitation the
  7. * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. * sell copies of the Software, and to permit persons to whom the Software is
  9. * furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  17. * GROUPE BULL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
  18. * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  19. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  20. *
  21. * Except as contained in this notice, the name of GROUPE BULL shall not be
  22. * used in advertising or otherwise to promote the sale, use or other dealings
  23. * in this Software without prior written authorization from GROUPE BULL.
  24. */
  25. /*****************************************************************************\
  26. * CrBufFrP.c: *
  27. * *
  28. * XPM library *
  29. * Scan a pixmap and possibly its mask and create an XPM buffer *
  30. * *
  31. * Developed by Arnaud Le Hors *
  32. \*****************************************************************************/
  33. #ifdef HAVE_CONFIG_H
  34. #include <config.h>
  35. #endif
  36. #include "XpmI.h"
  37. int
  38. XpmCreateBufferFromPixmap(
  39. Display *display,
  40. char **buffer_return,
  41. Pixmap pixmap,
  42. Pixmap shapemask,
  43. XpmAttributes *attributes)
  44. {
  45. XImage *ximage = NULL;
  46. XImage *shapeimage = NULL;
  47. unsigned int width = 0;
  48. unsigned int height = 0;
  49. int ErrorStatus;
  50. /* get geometry */
  51. if (attributes && attributes->valuemask & XpmSize) {
  52. width = attributes->width;
  53. height = attributes->height;
  54. }
  55. /* get the ximages */
  56. if (pixmap)
  57. xpmCreateImageFromPixmap(display, pixmap, &ximage, &width, &height);
  58. if (shapemask)
  59. xpmCreateImageFromPixmap(display, shapemask, &shapeimage,
  60. &width, &height);
  61. /* create the buffer */
  62. ErrorStatus = XpmCreateBufferFromImage(display, buffer_return, ximage,
  63. shapeimage, attributes);
  64. /* destroy the ximages */
  65. if (ximage)
  66. XDestroyImage(ximage);
  67. if (shapeimage)
  68. XDestroyImage(shapeimage);
  69. return (ErrorStatus);
  70. }