Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion graf2d/asimage/inc/TASImage.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class TASImage : public TImage {
TASImage &operator=(const TASImage &img);
~TASImage() override;

TObject *Clone(const char *newname) const override;
TObject *Clone(const char *newname = "") const override;

void SetEditable(Bool_t on = kTRUE) override { fEditable = on; } //*TOGGLE*
Bool_t IsEditable() const override { return fEditable; }
Expand Down
42 changes: 16 additions & 26 deletions graf2d/asimage/src/TASImage.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ TASImage::TASImage(const TASImage &img) : TImage(img)

if (img.IsValid()) {
fImage = clone_asimage(img.fImage, SCL_DO_ALL);
fScaledImage = fScaledImage ? (TASImage*)img.fScaledImage->Clone("") : nullptr;
fScaledImage = fScaledImage ? static_cast<TASImage *>(img.fScaledImage->Clone()) : nullptr;
fGrayImage = fGrayImage ? clone_asimage(img.fGrayImage, SCL_DO_ALL) : nullptr;

if (img.fImage->alt.vector) {
Expand Down Expand Up @@ -327,7 +327,7 @@ TASImage &TASImage::operator=(const TASImage &img)
DestroyImage();
delete fScaledImage;
fImage = clone_asimage(img.fImage, SCL_DO_ALL);
fScaledImage = fScaledImage ? (TASImage*)img.fScaledImage->Clone("") : nullptr;
fScaledImage = fScaledImage ? static_cast<TASImage *>(img.fScaledImage->Clone()) : nullptr;
fGrayImage = fGrayImage ? clone_asimage(img.fGrayImage, SCL_DO_ALL) : nullptr;

if (img.fImage->alt.vector) {
Expand All @@ -336,7 +336,7 @@ TASImage &TASImage::operator=(const TASImage &img)
memcpy(fImage->alt.vector, img.fImage->alt.vector, size);
}

fScaledImage = img.fScaledImage ? (TASImage*)img.fScaledImage->Clone("") : nullptr;
fScaledImage = img.fScaledImage ? static_cast<TASImage *>(img.fScaledImage->Clone()) : nullptr;
fZoomUpdate = kNoZoom;
fZoomOffX = img.fZoomOffX;
fZoomOffY = img.fZoomOffY;
Expand Down Expand Up @@ -2788,7 +2788,7 @@ TObject *TASImage::Clone(const char *newname) const
return nullptr;
}

TASImage *im = (TASImage*)TImage::Create();
TASImage *im = static_cast<TASImage *>(TImage::Create());

if (!im) {
Warning("Clone", "Failed to create image");
Expand All @@ -2805,7 +2805,7 @@ TObject *TASImage::Clone(const char *newname) const
im->fZoomWidth = fZoomWidth;
im->fZoomHeight = fZoomHeight;
im->fZoomUpdate = fZoomUpdate;
im->fScaledImage = fScaledImage ? (TASImage*)fScaledImage->Clone("") : nullptr;
im->fScaledImage = fScaledImage ? static_cast<TASImage *>(fScaledImage->Clone()) : nullptr;

if (fImage->alt.argb32) {
UInt_t sz = fImage->width * fImage->height;
Expand Down Expand Up @@ -6739,34 +6739,24 @@ void TASImage::SavePrimitive(std::ostream &out, Option_t * /*= ""*/)
{
char *buf = nullptr;
int sz;

if (GetWidth() > 500) { // workaround CINT limitations
UInt_t w = 500;
Double_t scale = 500./GetWidth();
UInt_t h = TMath::Nint(GetHeight()*scale);
Scale(w, h);
}

GetImageBuffer(&buf, &sz, TImage::kXpm);
TString str = buf;
free(buf);

TString name = GetName();
name.ReplaceAll(".", "_");
str.ReplaceAll("static", "const");
static int ii = 0;
ii++;

str.ReplaceAll("static", "const");
TString xpm = "xpm_";
xpm += name;
xpm += ii;
TString xpm = TString::Format("asimage_xpm_%d", ii++);
str.ReplaceAll("asxpm", xpm.Data());
out << std::endl << str << std::endl << std::endl;

out << " TImage *";
out << xpm << "_img = TImage::Create();" << std::endl;
out << " " << xpm << "_img->SetImageBuffer( (char **)" << xpm << ", TImage::kXpm);" << std::endl;
out << " " << xpm << "_img->Draw();" << std::endl;
out << "\n" << str << "\n\n";

out << " ";
if (!gROOT->ClassSaved(TImage::Class()))
out << TImage::Class()->GetName() << " *";
out << "asimage = TImage::Create();\n";
out << " asimage->SetImageBuffer( (char **)" << xpm << ", TImage::kXpm);\n";
SaveImageAttributes(out, "asimage");
out << " asimage->Draw();\n";
}

////////////////////////////////////////////////////////////////////////////////
Expand Down
2 changes: 1 addition & 1 deletion graf2d/graf/inc/TAttImage.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class TAttImage {

virtual void ResetAttImage(Option_t *option="");
virtual void SaveImageAttributes(std::ostream &out, const char *name,
EImageQuality qualdef = kImgDefault,
EImageQuality qualdef = kImgPoor,
UInt_t comprdef = 0,
Bool_t constRatiodef = kTRUE);
virtual void SetConstRatio(Bool_t constRatio = kTRUE); // *TOGGLE*
Expand Down
2 changes: 1 addition & 1 deletion graf2d/graf/inc/TImage.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ friend TImage operator/(const TImage &i1, const TImage &s2);
~TImage() override { }

// Cloning
TObject *Clone(const char *) const override { return nullptr; }
TObject *Clone(const char * = "") const override { return nullptr; }

// Input / output
virtual void ReadImage(const char * /*file*/, EImageFileTypes /*type*/ = TImage::kUnknown) {}
Expand Down
20 changes: 13 additions & 7 deletions graf2d/graf/src/TAttImage.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -610,14 +610,20 @@ void TAttImage::SaveImageAttributes(std::ostream &out, const char *name,
UInt_t comprdef, Bool_t constRatiodef)
{
if (fImageQuality != qualdef) {
out<<" "<<name<<"->SetImageQuality("<<fImageQuality<<");"<<std::endl;
}
if (fImageCompression != comprdef) {
out<<" "<<name<<"->SetImageCompression("<<fImageCompression<<");"<<std::endl;
}
if (fConstRatio != constRatiodef) {
out<<" "<<name<<"->SetConstRatio("<<fConstRatio<<");"<<std::endl;
out << " " << name << "->SetImageQuality(TAttImage::";
switch (fImageQuality) {
case kImgPoor: out << "kImgPoor"; break;
case kImgFast: out << "kImgFast"; break;
case kImgGood: out << "kImgGood"; break;
case kImgBest: out << "kImgBest"; break;
default: out << "kImgDefault";
}
out << ");\n";
}
if (fImageCompression != comprdef)
out << " " << name << "->SetImageCompression(" << fImageCompression << ");\n";
if (fConstRatio != constRatiodef)
out << " " << name << "->SetConstRatio(" << (fConstRatio ? "kTRUE" : "kFALSE") << ");\n";
}

////////////////////////////////////////////////////////////////////////////////
Expand Down
39 changes: 22 additions & 17 deletions test/stressGraphics.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -3640,28 +3640,30 @@ void timage()
{
TCanvas *C = StartTest(800,800);

TImage *img = TImage::Open("$(ROOTSYS)/tutorials/visualisation/image/rose512.jpg");
TString fname = gROOT->GetTutorialDir();
fname.Append("/visualisation/image/rose512.jpg");
TImage *img = TImage::Open(fname);
if (!img) {
printf("Could not create an image... exit\n");
return;
}
TImage *i1 = TImage::Open("$(ROOTSYS)/tutorials/visualisation/image/rose512.jpg");
auto i1 = (TImage *) img->Clone();
i1->SetConstRatio(kFALSE);
i1->Flip(90);
TImage *i2 = TImage::Open("$(ROOTSYS)/tutorials/visualisation/image/rose512.jpg");
auto i2 = (TImage *) img->Clone();
i2->SetConstRatio(kFALSE);
i2->Flip(180);
TImage *i3 = TImage::Open("$(ROOTSYS)/tutorials/visualisation/image/rose512.jpg");
auto i3 = (TImage *) img->Clone();
i3->SetConstRatio(kFALSE);
i3->Flip(270);
TImage *i4 = TImage::Open("$(ROOTSYS)/tutorials/visualisation/image/rose512.jpg");
i4->SetConstRatio(kFALSE);
i4->Mirror(kTRUE);

img->SetConstRatio(kFALSE);
img->Mirror(kTRUE);
float d = 0.40;
TPad *p1 = new TPad("i1", "i1", 0.05, 0.55, 0.05+d*i1->GetWidth()/i1->GetHeight(), 0.95);
TPad *p2 = new TPad("i2", "i2", 0.55, 0.55, 0.95, 0.55+d*i2->GetHeight()/i2->GetWidth());
TPad *p3 = new TPad("i3", "i3", 0.55, 0.05, 0.55+d*i3->GetWidth()/i3->GetHeight(), 0.45);
TPad *p4 = new TPad("i4", "i4", 0.05, 0.05, 0.45, 0.05+d*i4->GetHeight()/i4->GetWidth());
TPad *p4 = new TPad("i4", "i4", 0.05, 0.05, 0.45, 0.05+d*img->GetHeight()/img->GetWidth());
p1->Draw();
p1->cd();
i1->Draw();
Expand All @@ -3676,7 +3678,7 @@ void timage()
C->cd();
p4->Draw();
p4->cd();
i4->Draw();
img->Draw();
C->cd();

TestReport(C, "timage", "TImage");
Expand Down Expand Up @@ -4371,16 +4373,19 @@ void stressGraphics(Int_t verbose = 0, Bool_t generate = kFALSE, Bool_t keep_fil
// only in batch web mode use
gWebMode = gROOT->IsWebDisplay();

// Check if $ROOTSYS/tutorials/hsimple.root exists
gHsimple = TFile::Open("$(ROOTSYS)/tutorials/hsimple.root");
// Check if hsimple.root exists

TString dir = gROOT->GetTutorialDir();

gHsimple = TFile::Open(dir + "/hsimple.root");
if (!gHsimple) {
gHsimple = TFile::Open("hsimple.root");
if (!gHsimple) {
printf("Create $(ROOTSYS)/tutorials/hsimple.root\n");
gROOT->Macro("$(ROOTSYS)/tutorials/hsimple.C");
gHsimple = TFile::Open("$(ROOTSYS)/tutorials/hsimple.root");
printf("Create hsimple.root\n");
gROOT->Macro(dir + "/hsimple.C");
gHsimple = TFile::Open("hsimple.root");
if (!gHsimple) {
printf("Could not create $(ROOTSYS)/tutorials/hsimple.root\n");
printf("Could not create hsimple.root\n");
return;
}
}
Expand All @@ -4389,10 +4394,10 @@ void stressGraphics(Int_t verbose = 0, Bool_t generate = kFALSE, Bool_t keep_fil
// Check if cernstaff.root exists
gCernstaff = TFile::Open("cernstaff.root");
if (!gCernstaff) {
gCernstaff = TFile::Open("$(ROOTSYS)/tutorials/io/tree/cernstaff.root");
gCernstaff = TFile::Open(dir + "/io/tree/cernstaff.root");
if (!gCernstaff) {
printf("Create ./cernstaff.root\n");
gROOT->Macro("$(ROOTSYS)/tutorials/io/tree/tree500_cernbuild.C(0,0)");
gROOT->Macro(dir + "/io/tree/tree500_cernbuild.C(0,0)");
gCernstaff = TFile::Open("cernstaff.root");
if (!gCernstaff) {
printf("Could not create ./cernstaff.root\n");
Expand Down
14 changes: 9 additions & 5 deletions tutorials/visualisation/image/img2pad.C
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,15 @@

void img2pad()
{
TImage *img = TImage::Open("$ROOTSYS/tutorials/visualisation/image/rose512.jpg");
TString fname = gROOT->GetTutorialDir();
fname.Append("/visualisation/image/rose512.jpg");
TImage *img = TImage::Open(fname);

if (!img) {
printf("Could not create an image... exit\n");
return;
}

img->SetConstRatio(kFALSE);
img->Draw("N");

Expand All @@ -26,16 +30,16 @@ void img2pad()
/*img->Draw("T100,100,#556655");*/
/*img->Draw("T100,100");*/

TImage *i1 = TImage::Open("$ROOTSYS/tutorials/visualisation/image/rose512.jpg");
TImage *i1 = TImage::Open(fname);
i1->SetConstRatio(kFALSE);
i1->Flip(90);
TImage *i2 = TImage::Open("$ROOTSYS/tutorials/visualisation/image/rose512.jpg");
TImage *i2 = TImage::Open(fname);
i2->SetConstRatio(kFALSE);
i2->Flip(180);
TImage *i3 = TImage::Open("$ROOTSYS/tutorials/visualisation/image/rose512.jpg");
TImage *i3 = TImage::Open(fname);
i3->SetConstRatio(kFALSE);
i3->Flip(270);
TImage *i4 = TImage::Open("$ROOTSYS/tutorials/visualisation/image/rose512.jpg");
TImage *i4 = TImage::Open(fname);
i4->SetConstRatio(kFALSE);
i4->Mirror(kTRUE);

Expand Down
Loading