Logo ROOT   6.08/07
Reference Guide
QuartzPixmap.h
Go to the documentation of this file.
1 // @(#)root/graf2d:$Id$
2 // Author: Timur Pocheptsov 16/02/2012
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2012, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 
13 #ifndef ROOT_QuartzPixmap
14 #define ROOT_QuartzPixmap
15 
16 #include <vector>
17 
18 #include <Cocoa/Cocoa.h>
19 
20 #ifndef ROOT_CocoaGuiTypes
21 #include "CocoaGuiTypes.h"
22 #endif
23 #ifndef ROOT_CocoaUtils
24 #include "CocoaUtils.h"
25 #endif
26 #ifndef ROOT_X11Drawable
27 #include "X11Drawable.h"
28 #endif
29 #ifndef ROOT_GuiTypes
30 #include "GuiTypes.h"
31 #endif
32 
33 ///////////////////////////////////////////////////////
34 // //
35 // "Pixmap". Graphical context to draw into image. //
36 // //
37 ///////////////////////////////////////////////////////
38 
39 @interface QuartzPixmap : NSObject<X11Drawable> {
40 @private
41  //32-bit Obj-C requires i-var to be declared (for a synthesized prop.).
42  unsigned fID;
43  //
44 
45  unsigned fWidth;
46  unsigned fHeight;
47 
48  std::vector<unsigned char> fData;
50 
51  unsigned fScaleFactor;
52 }
53 
54 - (id) initWithW : (unsigned) width H : (unsigned) height scaleFactor : (CGFloat) scaleFactor;
55 - (BOOL) resizeW : (unsigned) width H : (unsigned) height scaleFactor : (CGFloat) scaleFactor;
56 
57 - (CGImageRef) createImageFromPixmap;
58 - (CGImageRef) createImageFromPixmap : (ROOT::MacOSX::X11::Rectangle) cropArea;
59 
60 //X11Drawable protocol.
61 
62 @property (nonatomic, assign) unsigned fID;
63 
64 - (BOOL) fIsPixmap;
65 - (BOOL) fIsOpenGLWidget;
66 
67 @property (nonatomic, readonly) CGContextRef fContext;
68 
69 - (unsigned) fWidth;
70 - (unsigned) fHeight;
71 
72 - (void) copy : (NSObject<X11Drawable> *) src area : (ROOT::MacOSX::X11::Rectangle) area withMask : (QuartzImage *) mask
73  clipOrigin : (ROOT::MacOSX::X11::Point) origin toPoint : (ROOT::MacOSX::X11::Point) dstPoint;
74 
75 - (unsigned char *) readColorBits : (ROOT::MacOSX::X11::Rectangle) area;
76 
77 //
78 - (unsigned char *) fData;
79 
80 //XPutPixel.
81 - (void) putPixel : (const unsigned char *) data X : (unsigned) x Y : (unsigned) y;
82 //XAddPixel.
83 - (void) addPixel : (const unsigned char *) rgb;
84 
85 @end
86 
87 /////////////////////////////////////////////////////////
88 // //
89 // CGImageRef, created from external data source (raw //
90 // data) //
91 // //
92 /////////////////////////////////////////////////////////
93 
94 //TODO: split image and mask image?
95 
96 @interface QuartzImage : NSObject<X11Drawable> {
97 @private
98  //32-bit Obj-C requires i-var to be declared (for a synthesized prop.).
100  unsigned fID;
101  //
102  unsigned fWidth;
103  unsigned fHeight;
104 
106  std::vector<unsigned char> fImageData;
107 }
108 
109 - (id) initWithW : (unsigned) width H : (unsigned) height data : (unsigned char *) data;
110 - (id) initMaskWithW : (unsigned) width H : (unsigned) height bitmapMask : (unsigned char *) mask;
111 - (id) initMaskWithW : (unsigned) width H : (unsigned) height;
112 - (id) initFromPixmap : (QuartzPixmap *) pixmap;
113 - (id) initFromImage : (QuartzImage *) image;
114 - (id) initFromImageFlipped : (QuartzImage *) image;
115 
116 @property (nonatomic, readonly) BOOL fIsStippleMask;
117 - (CGImageRef) fImage;
118 
119 //X11Drawable protocol.
120 @property (nonatomic, assign) unsigned fID;
121 
122 - (BOOL) fIsPixmap;
123 - (BOOL) fIsOpenGLWidget;
124 
125 - (unsigned) fWidth;
126 - (unsigned) fHeight;
127 
128 - (unsigned char *) readColorBits : (ROOT::MacOSX::X11::Rectangle) area;
129 
130 @end
131 
132 
133 namespace ROOT {
134 namespace MacOSX {
135 namespace X11 {
136 
137 CGImageRef CreateSubImage(QuartzImage *image, const Rectangle &area);
138 //
139 bool AdjustCropArea(const Rectangle &srcRect, Rectangle &cropArea);
140 bool AdjustCropArea(QuartzImage *srcImage, Rectangle &cropArea);
141 bool AdjustCropArea(QuartzImage *srcImage, NSRect &cropArea);
142 bool AdjustCropArea(QuartzPixmap *srcImage, Rectangle &cropArea);
143 
144 //Aux. function for TGCocoa.
145 void FillPixmapBuffer(const unsigned char *bitmap, unsigned width, unsigned height, ULong_t foregroundPixel,
146  ULong_t backgroundPixel, unsigned depth, unsigned char *imageData);
147 
148 }
149 }
150 }
151 
152 #endif
BOOL fIsStippleMask
Definition: QuartzPixmap.h:99
unsigned char * fData()
std::vector< unsigned char > fData
Definition: QuartzPixmap.h:48
ROOT::MacOSX::Util::CFScopeGuard< CGImageRef > fImage
Definition: QuartzPixmap.h:105
This namespace contains pre-defined functions to be used in conjuction with TExecutor::Map and TExecu...
Definition: StringConv.hxx:21
unsigned fID
Definition: QuartzPixmap.h:42
unsigned fScaleFactor
Definition: QuartzPixmap.h:51
unsigned fHeight()
void FillPixmapBuffer(const unsigned char *bitmap, unsigned width, unsigned height, ULong_t foregroundPixel, ULong_t backgroundPixel, unsigned depth, unsigned char *imageData)
unsigned fHeight
Definition: QuartzPixmap.h:103
unsigned fHeight
Definition: QuartzPixmap.h:46
CGImageRef CreateSubImage(QuartzImage *image, const Rectangle &area)
XFontStruct * id
Definition: TGX11.cxx:108
BOOL fIsOpenGLWidget()
CGImageRef createImageFromPixmap()
unsigned fWidth
Definition: QuartzPixmap.h:102
ROOT::MacOSX::Util::CFScopeGuard< CGContextRef > fContext
Definition: QuartzPixmap.h:49
bool AdjustCropArea(QuartzPixmap *srcImage, Rectangle &cropArea)
unsigned fWidth()
unsigned fWidth
Definition: QuartzPixmap.h:45
std::vector< unsigned char > fImageData
Definition: QuartzPixmap.h:106
unsigned long ULong_t
Definition: RtypesCore.h:51
typedef void((*Func_t)())
unsigned fID
Definition: QuartzPixmap.h:100