b_openpl.c 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /* This file is part of the GNU plotutils package. Copyright (C) 1995,
  2. 1996, 1997, 1998, 1999, 2000, 2005, 2008, Free Software Foundation, Inc.
  3. The GNU plotutils package is free software. You may redistribute it
  4. and/or modify it under the terms of the GNU General Public License as
  5. published by the Free Software foundation; either version 2, or (at your
  6. option) any later version.
  7. The GNU plotutils package is distributed in the hope that it will be
  8. useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. General Public License for more details.
  11. You should have received a copy of the GNU General Public License along
  12. with the GNU plotutils package; see the file COPYING. If not, write to
  13. the Free Software Foundation, Inc., 51 Franklin St., Fifth Floor,
  14. Boston, MA 02110-1301, USA. */
  15. #include "sys-defines.h"
  16. #include "extern.h"
  17. #include "xmi.h"
  18. bool
  19. _pl_b_begin_page (S___(Plotter *_plotter))
  20. {
  21. /* create new pixmap of specified size (all pixels of background color) */
  22. _pl_b_new_image (S___(_plotter));
  23. return true;
  24. }
  25. /* internal function: create new image, consisting of a bitmap; also fill
  26. with Plotter's background color */
  27. void
  28. _pl_b_new_image (S___(Plotter *_plotter))
  29. {
  30. unsigned char red, green, blue;
  31. miPixel pixel;
  32. /* compute 24-bit bg color, and construct a miPixel for it */
  33. red = ((unsigned int)(_plotter->drawstate->bgcolor.red) >> 8) & 0xff;
  34. green = ((unsigned int)(_plotter->drawstate->bgcolor.green) >> 8) & 0xff;
  35. blue = ((unsigned int)(_plotter->drawstate->bgcolor.blue) >> 8) & 0xff;
  36. pixel.type = MI_PIXEL_RGB_TYPE;
  37. pixel.u.rgb[0] = red;
  38. pixel.u.rgb[1] = green;
  39. pixel.u.rgb[2] = blue;
  40. /* create libxmi miPaintedSet and miCanvas structs */
  41. _plotter->b_painted_set = (void *)miNewPaintedSet ();
  42. _plotter->b_canvas = (void *)miNewCanvas ((unsigned int)_plotter->b_xn, (unsigned int)_plotter->b_yn, pixel);
  43. }