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