#include "FWTEveViewer.h"
|
static bool | SaveJpg (const TString &file, UChar_t *xx, int ww, int hh) |
|
static bool | SavePng (const TString &file, UChar_t *xx, int ww, int hh) |
|
Description: [one line class summary]
Usage: <usage>
Definition at line 35 of file FWTEveViewer.h.
FWTEveViewer::FWTEveViewer |
( |
const char * |
n = "FWTEveViewer" , |
|
|
const char * |
t = "" |
|
) |
| |
FWTEveViewer::~FWTEveViewer |
( |
| ) |
|
|
virtual |
std::thread FWTEveViewer::CaptureAndSaveImage |
( |
const TString & |
file, |
|
|
int |
height = -1 |
|
) |
| |
Definition at line 87 of file FWTEveViewer.cc.
References m_fwGlViewer, FWTGLViewer::MakeFbo(), FWTGLViewer::MakeFboHeight(), SaveJpg(), and SavePng().
89 static const TString eh(
"FWTEveViewer::CaptureAndSaveImage");
99 ::Error(eh,
"Returned FBO is 0.");
100 return std::thread();
104 if (fbo->fIsRescaled)
106 ww = TMath::Nint(fbo->fW * fbo->fWScale);
107 hh = TMath::Nint(fbo->fH * fbo->fHScale);
115 fbo->SetAsReadBuffer();
117 UChar_t* xx =
new UChar_t[3 * ww * hh];
118 glPixelStorei(GL_PACK_ALIGNMENT, 1);
119 glReadPixels(0, 0, ww, hh, GL_RGB, GL_UNSIGNED_BYTE, xx);
123 std::thread thr([=]()
125 if (
file.EndsWith(
".jpg"))
TGLFBO * MakeFboHeight(Int_t height, Bool_t pixel_object_scale=kTRUE)
static bool SaveJpg(const TString &file, UChar_t *xx, int ww, int hh)
FWTGLViewer * m_fwGlViewer
static bool SavePng(const TString &file, UChar_t *xx, int ww, int hh)
bool FWTEveViewer::SaveJpg |
( |
const TString & |
file, |
|
|
UChar_t * |
xx, |
|
|
int |
ww, |
|
|
int |
hh |
|
) |
| |
|
static |
Definition at line 228 of file FWTEveViewer.cc.
References i, j, tablePrinter::rows, and TRUE.
Referenced by CaptureAndSaveImage().
230 struct jpeg_compress_struct JpegInfo;
231 struct jpeg_error_mgr Error;
233 JpegInfo.err = jpeg_std_error(&Error);
236 jpeg_create_compress(&JpegInfo);
238 FILE *fp = fopen(
file,
"w");
239 jpeg_stdio_dest(&JpegInfo, fp);
241 JpegInfo.image_width = ww;
242 JpegInfo.image_height = hh;
243 JpegInfo.input_components = 3;
244 JpegInfo.in_color_space = JCS_RGB;
246 jpeg_set_defaults(&JpegInfo);
248 JpegInfo.write_JFIF_header =
TRUE;
254 jpeg_start_compress(&JpegInfo,
TRUE);
256 std::vector<UChar_t*>
rows(hh);
259 for (
int i = 0;
i < hh;
i++, j--) {
260 rows[
i] = xx + j * ww * 3;
264 jpeg_write_scanlines(&JpegInfo, &
rows[0], hh);
267 jpeg_finish_compress(&JpegInfo);
272 jpeg_destroy_compress(&JpegInfo);
bool FWTEveViewer::SavePng |
( |
const TString & |
file, |
|
|
UChar_t * |
xx, |
|
|
int |
ww, |
|
|
int |
hh |
|
) |
| |
|
static |
Definition at line 148 of file FWTEveViewer.cc.
References i, j, NULL, and tablePrinter::rows.
Referenced by CaptureAndSaveImage().
159 png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING,
NULL, 0, 0);
160 if (png_ptr ==
NULL) {
161 printf(
"Error creating png write struct\n");
166 info_ptr = png_create_info_struct(png_ptr);
167 if (info_ptr ==
NULL) {
168 printf(
"Error creating png info struct\n");
169 png_destroy_write_struct(&png_ptr, &info_ptr);
182 FILE *fp = fopen(
file,
"w");
184 png_init_io(png_ptr, fp);
188 png_set_IHDR(png_ptr, info_ptr, ww, hh, 8, PNG_COLOR_TYPE_RGB,
189 PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
204 png_write_info(png_ptr, info_ptr);
206 std::vector<UChar_t*>
rows(hh);
209 for (
int i = 0;
i < hh;
i++, j--) {
210 rows[
i] = xx + j * ww * 3;
215 png_write_image(png_ptr, &
rows[0]);
218 png_write_end(png_ptr, info_ptr);
221 png_destroy_write_struct(&png_ptr, &info_ptr);
Definition at line 70 of file FWTEveViewer.cc.
References m_fwGlViewer.
Referenced by FWEveView::FWEveView().
72 TGCompositeFrame* cf = GetGUICompositeFrame();
77 cf->AddFrame(fGLViewerFrame,
new TGLayoutHints(kLHintsNormal | kLHintsExpandX | kLHintsExpandY));
79 fGLViewerFrame->MapWindow();
FWTGLViewer * m_fwGlViewer