35 : TGFrame(p, w, h, options, back), fWidth(w), fHeight(h)
46 Resize(GetWidth(), GetHeight());
54 cout <<
"Detected Color Depth: " << gVirtualX->GetDepth() << endl;
62 cout <<
"Deleting MGImage..." << endl;
64 gVirtualX->DeleteGC(
fDefGC);
65 gVirtualX->DeleteImage((Drawable_t)
fImage);
71 cout <<
"MGImage destroyed." << endl;
94 cout <<
"MGImage::DoRedraw - tried to unlock mutex locked by other thread." << endl;
108 *d++ = (*s&0xf8)<<8 | (*s&0xfc)<<3 | (*s>>3);
136 cout <<
"MGImage::DrawImg - mutex is already locked by this thread" << endl;
141 switch (gVirtualX->GetDepth())
153 cout <<
"Sorry, " << gVirtualX->GetDepth() <<
"bit color depth not yet implemented." << endl;
159 cout <<
"MGImage::DrawImage - tried to unlock mutex locked by other thread." << endl;
174 *d++ = (*s2&0x3)<<3 | (*s2&0xb)<<6 | (*s2&0x30)<<10;
179 *d++ = (*s1&0xfc) | (*s1&0xf8)<<5 | (*s1&0xfc)<<11;
193 *d++ = ((*s2>>4)&0x3)*85;
194 *d++ = ((*s2>>2)&0x3)*85;
195 *d++ = ((*s2++ )&0x3)*85;
219 cout <<
"MGImage::DrawColImg - mutex is already locked by this thread" << endl;
237 switch (gVirtualX->GetDepth())
246 cout <<
"Sorry, " << gVirtualX->GetDepth() <<
"bit color depth not yet implemented." << endl;
252 cout <<
"MGImage::DrawColImage - tried to unlock mutex locked by other thread." << endl;
263 case kBlack:
return 0;
268 case kBlue:
return 2<<4;
279 void MGImage::DrawLine(UChar_t *buf,
int w,
int h, Float_t x1, Float_t y1, Float_t x2, Float_t y2, UChar_t col, Int_t style)
281 const Int_t step = style==kSolid?1:3;
282 const Double_t len = TMath::Hypot(x2-x1, y2-y1);
283 const Double_t dx = (x2-x1)/len*step;
284 const Double_t dy = (y2-y1)/len*step;
289 for (
int i=0;
i<len;
i+=step)
294 const Int_t iy = TMath::Nint(y);
298 const Int_t ix = TMath::Nint(x);
311 void MGImage::DrawBox(UChar_t *buf,
int w,
int h, Float_t x1, Float_t y1, Float_t x2, Float_t y2, UChar_t col, Int_t style)
313 DrawLine(buf, w, h, x1, y1, x2, y1, col, style);
314 DrawLine(buf, w, h, x1, y2, x2, y1, col, style);
315 DrawLine(buf, w, h, x1, y1, x1, y2, col, style);
316 DrawLine(buf, w, h, x2, y1, x2, y2, col, style);
324 void MGImage::DrawHexagon(UChar_t *buf,
int w,
int h, Float_t px, Float_t py, Float_t d, UChar_t col, Int_t style)
328 const Double_t dy[np+1] = { .5 , 0. , -.5 , -.5 , 0. , .5 , .5 };
329 const Double_t dx[np+1] = { .2886, .5772, .2886, -.2886, -.5772, -.2886, .2886 };
334 Double_t x[np+1], y[np+1];
335 for (Int_t
i=0;
i<np+1;
i++)
341 for (
int i=0;
i<6;
i++)
342 DrawLine(buf, w, h, x[
i], y[i], x[i+1], y[i+1], col, style);
352 const Int_t n = TMath::Nint(sqrt(2.)*r*TMath::Pi()/2);
353 for (
int i=0;
i<n-1;
i++)
355 const Double_t angle = TMath::TwoPi()*
i/n;
357 const Double_t dx = r*cos(angle);
358 const Double_t dy = r*sin(angle);
360 const Int_t x1 = TMath::Nint(x+dx);
361 const Int_t x2 = TMath::Nint(x-dx);
363 const Int_t y1 = TMath::Nint(y+dy);
373 const Int_t y2 = TMath::Nint(y-dy);
391 const Int_t x1 = TMath::Nint(cx);
392 const Int_t y1 = TMath::Nint(cy);
394 if (x1>=0 && y1>=0 && x1<w && y1<h)
421 DrawLine(buf, w, h, cx-size, cy-size, cx+size, cy+size, col);
422 DrawLine(buf, w, h, cx+size, cy-size, cx-size, cy+size, col);
427 DrawLine(buf, w, h, cx-size, cy, cx+size, cy, col);
428 DrawLine(buf, w, h, cx, cy-size, cx, cy+size, col);
static void DrawHexagon(UChar_t *buf, int w, int h, Float_t x, Float_t y, Float_t r, UChar_t col, Int_t style=1)
void DrawColImg(const byte *gbuf, const byte *cbuf)
void DrawColImg16(unsigned short *d, char *s1, char *s2, char *e)
static void DrawMultiply(UChar_t *buf, int w, int h, Float_t cx, Float_t cy, Float_t size, UChar_t col)
static void DrawCross(UChar_t *buf, int w, int h, Float_t cx, Float_t cy, Float_t size, UChar_t col)
static UChar_t Color(int col)
static void DrawLine(UChar_t *buf, int w, int h, Float_t x1, Float_t y1, Float_t x2, Float_t y2, UChar_t col, Int_t style=1)
void DrawImg16(unsigned short *d, char *s, char *e)
static void DrawDot(UChar_t *buf, int w, int h, Float_t cx, Float_t cy, UChar_t col)
MGImage(const TGWindow *p, UInt_t w, UInt_t h, UInt_t options=kSunkenFrame, ULong_t back=fgDefaultFrameBackground)
void DrawColImg24(char *d, char *s1, char *s2, char *e)
void DrawImg(const byte *buffer)
static void DrawCircle(UChar_t *buf, int w, int h, Float_t x, Float_t y, Float_t r, UChar_t col)
void DrawImg24(char *d, char *s, char *e)
static void DrawBox(UChar_t *buf, int w, int h, Float_t x1, Float_t y1, Float_t x2, Float_t y2, UChar_t col, Int_t style=1)