Logo ROOT   6.12/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 #include "CocoaGuiTypes.h"
21 #include "CocoaUtils.h"
22 #include "X11Drawable.h"
23 #include "GuiTypes.h"
24 
25 ///////////////////////////////////////////////////////
26 // //
27 // "Pixmap". Graphical context to draw into image. //
28 // //
29 ///////////////////////////////////////////////////////
30 
31 @interface QuartzPixmap : NSObject<X11Drawable> {
32 @private
33  //32-bit Obj-C requires i-var to be declared (for a synthesized prop.).
34  unsigned fID;
35  //
36 
37  unsigned fWidth;
38  unsigned fHeight;
39 
40  std::vector<unsigned char> fData;
42 
43  CGFloat fScaleFactor;
44 }
45 
46 - (id) initWithW : (unsigned) width H : (unsigned) height scaleFactor : (CGFloat) scaleFactor;
47 - (BOOL) resizeW : (unsigned) width H : (unsigned) height scaleFactor : (CGFloat) scaleFactor;
48 
49 - (CGImageRef) createImageFromPixmap;
50 - (CGImageRef) createImageFromPixmap : (ROOT::MacOSX::X11::Rectangle) cropArea;
51 
52 //X11Drawable protocol.
53 
54 @property (nonatomic, assign) unsigned fID;
55 
56 - (BOOL) fIsPixmap;
57 - (BOOL) fIsOpenGLWidget;
58 - (CGFloat) fScaleFactor;
59 
60 @property (nonatomic, readonly) CGContextRef fContext;
61 
62 - (unsigned) fWidth;
63 - (unsigned) fHeight;
64 
65 - (void) copy : (NSObject<X11Drawable> *) src area : (ROOT::MacOSX::X11::Rectangle) area withMask : (QuartzImage *) mask
66  clipOrigin : (ROOT::MacOSX::X11::Point) origin toPoint : (ROOT::MacOSX::X11::Point) dstPoint;
67 
68 - (unsigned char *) readColorBits : (ROOT::MacOSX::X11::Rectangle) area;
69 
70 //
71 - (unsigned char *) fData;
72 
73 //XPutPixel.
74 - (void) putPixel : (const unsigned char *) data X : (unsigned) x Y : (unsigned) y;
75 //XAddPixel.
76 - (void) addPixel : (const unsigned char *) rgb;
77 
78 @end
79 
80 /////////////////////////////////////////////////////////
81 // //
82 // CGImageRef, created from external data source (raw //
83 // data) //
84 // //
85 /////////////////////////////////////////////////////////
86 
87 @interface QuartzImage : NSObject<X11Drawable> {
88 @private
89  //32-bit Obj-C requires i-var to be declared (for a synthesized prop.).
91  unsigned fID;
92  //
93  unsigned fWidth;
94  unsigned fHeight;
95 
97  std::vector<unsigned char> fImageData;
98 }
99 
100 - (id) initWithW : (unsigned) width H : (unsigned) height data : (unsigned char *) data;
101 - (id) initMaskWithW : (unsigned) width H : (unsigned) height bitmapMask : (unsigned char *) mask;
102 - (id) initMaskWithW : (unsigned) width H : (unsigned) height;
103 - (id) initFromPixmap : (QuartzPixmap *) pixmap;
104 - (id) initFromImage : (QuartzImage *) image;
105 - (id) initFromImageFlipped : (QuartzImage *) image;
106 
107 @property (nonatomic, readonly) BOOL fIsStippleMask;
108 - (CGImageRef) fImage;
109 
110 //X11Drawable protocol.
111 @property (nonatomic, assign) unsigned fID;
112 
113 - (BOOL) fIsPixmap;
114 - (BOOL) fIsOpenGLWidget;
115 
116 - (unsigned) fWidth;
117 - (unsigned) fHeight;
118 
119 - (unsigned char *) readColorBits : (ROOT::MacOSX::X11::Rectangle) area;
120 
121 @end
122 
123 
124 namespace ROOT {
125 namespace MacOSX {
126 namespace X11 {
127 
128 CGImageRef CreateSubImage(QuartzImage *image, const Rectangle &area);
129 //
130 bool AdjustCropArea(const Rectangle &srcRect, Rectangle &cropArea);
131 bool AdjustCropArea(QuartzImage *srcImage, Rectangle &cropArea);
132 bool AdjustCropArea(QuartzImage *srcImage, NSRect &cropArea);
133 bool AdjustCropArea(QuartzPixmap *srcImage, Rectangle &cropArea);
134 
135 //Aux. function for TGCocoa.
136 void FillPixmapBuffer(const unsigned char *bitmap, unsigned width, unsigned height, ULong_t foregroundPixel,
137  ULong_t backgroundPixel, unsigned depth, unsigned char *imageData);
138 
139 }
140 }
141 }
142 
143 #endif
BOOL fIsStippleMask
Definition: QuartzPixmap.h:90
unsigned char * fData()
std::vector< unsigned char > fData
Definition: QuartzPixmap.h:40
ROOT::MacOSX::Util::CFScopeGuard< CGImageRef > fImage
Definition: QuartzPixmap.h:96
Namespace for new ROOT classes and functions.
Definition: StringConv.hxx:21
unsigned fID
Definition: QuartzPixmap.h:34
CGFloat fScaleFactor
Definition: QuartzPixmap.h:43
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:94
unsigned fHeight
Definition: QuartzPixmap.h:38
CGImageRef CreateSubImage(QuartzImage *image, const Rectangle &area)
XFontStruct * id
Definition: TGX11.cxx:108
BOOL fIsOpenGLWidget()
CGImageRef createImageFromPixmap()
unsigned fWidth
Definition: QuartzPixmap.h:93
ROOT::MacOSX::Util::CFScopeGuard< CGContextRef > fContext
Definition: QuartzPixmap.h:41
CGFloat fScaleFactor()
bool AdjustCropArea(QuartzPixmap *srcImage, Rectangle &cropArea)
unsigned fWidth()
unsigned fWidth
Definition: QuartzPixmap.h:37
std::vector< unsigned char > fImageData
Definition: QuartzPixmap.h:97
unsigned long ULong_t
Definition: RtypesCore.h:51
typedef void((*Func_t)())
unsigned fID
Definition: QuartzPixmap.h:91