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
6 changes: 3 additions & 3 deletions graf2d/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ elseif(x11)
add_subdirectory(x11) # special CMakeLists.txt
add_subdirectory(x11ttf) # special CMakeLists.txt
endif()
if(asimage)
add_subdirectory(asimage) # special CMakeLists.txt
endif()

add_subdirectory(asimage) # special CMakeLists.txt

add_subdirectory(padpainter)
if(gviz)
add_subdirectory(gviz)
Expand Down
99 changes: 55 additions & 44 deletions graf2d/asimage/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,40 @@
############################################################################
# CMakeLists.txt file for building ROOT graf2d/asimage package
# @author Pere Mato, CERN
# @author Sergey Linev, GSI
############################################################################

ROOT_STANDARD_LIBRARY_PACKAGE(ASImage
NO_INSTALL_HEADERS
HEADERS
TASImage.h
TASImagePlugin.h
TASPluginGS.h
TASPngWriter.h
SOURCES
TASImage.cxx
TASPluginGS.cxx
TASPngWriter.cxx
DICTIONARY_OPTIONS
-writeEmptyRootPCM
LIBRARIES
libAfterImage
DEPENDENCIES
Core
Graf
Postscript
)
if(asimage)

ROOT_STANDARD_LIBRARY_PACKAGE(ASImage
NO_GLOB_HEADERS
HEADERS
TASImage.h
TASImagePlugin.h
TASPluginGS.h
TASPngWriter.h
SOURCES
TASImage.cxx
TASPluginGS.cxx
TASPngWriter.cxx
DICTIONARY_OPTIONS
-writeEmptyRootPCM
LIBRARIES
libAfterImage
DEPENDENCIES
Core
Graf
Postscript
)

if (x11)
target_link_libraries(ASImage PRIVATE X11::X11)
endif()

if (x11)
target_link_libraries(ASImage PRIVATE X11::X11)
endif()

ROOT_STANDARD_LIBRARY_PACKAGE(ASImageUtils
NO_INSTALL_HEADERS
NO_GLOB_HEADERS
HEADERS
TASUtils.h
SOURCES
Expand All @@ -44,30 +49,36 @@ ROOT_STANDARD_LIBRARY_PACKAGE(ASImageUtils
LinkDefUtils.h
DICTIONARY_OPTIONS
-writeEmptyRootPCM
LIBRARIES
libAfterImage
DEPENDENCIES
ASImage
Gpad
)

ROOT_STANDARD_LIBRARY_PACKAGE(ASImageGui
NO_INSTALL_HEADERS
HEADERS
TASPaletteEditor.h
SOURCES
src/TASPaletteEditor.cxx
LINKDEF
LinkDefGui.h
DICTIONARY_OPTIONS
-writeEmptyRootPCM
LIBRARIES
libAfterImage
DEPENDENCIES
Gui
ASImage
)

ROOT_INSTALL_HEADERS()
if(asimage)

ROOT_ADD_TEST_SUBDIRECTORY(test)
target_link_libraries(ASImageUtils PRIVATE libAfterImage)

target_link_libraries(ASImageUtils PUBLIC ASImage)

ROOT_STANDARD_LIBRARY_PACKAGE(ASImageGui
NO_GLOB_HEADERS
HEADERS
TASPaletteEditor.h
SOURCES
TASPaletteEditor.cxx
LINKDEF
LinkDefGui.h
DICTIONARY_OPTIONS
-writeEmptyRootPCM
LIBRARIES
libAfterImage
DEPENDENCIES
Gui
ASImage
)

ROOT_ADD_TEST_SUBDIRECTORY(test)

else()
target_compile_definitions(ASImageUtils PRIVATE NO_ASIMAGE)
endif()
2 changes: 1 addition & 1 deletion graf2d/asimage/inc/TASImage.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ friend class TASUtils; // to implement gVirtualX-specific methods
const char *GetTitle() const override;
const char *GetIconName() const override { return GetTitle(); }

void FromBitmap(const UChar_t *buf, UInt_t width, UInt_t height) override;
void FromBitmap(const UChar_t *buf, UInt_t width, UInt_t height, const UChar_t *mask = nullptr) override;
void FromPad(TVirtualPad *pad, Int_t x = 0, Int_t y = 0, UInt_t w = 0, UInt_t h = 0) override;
void FromWindow(Drawable_t wid, Int_t x = 0, Int_t y = 0, UInt_t w = 0, UInt_t h = 0) override;
void FromGLBuffer(UChar_t *buf, UInt_t width, UInt_t height) override;
Expand Down
4 changes: 2 additions & 2 deletions graf2d/asimage/src/TASImage.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -6353,12 +6353,12 @@ void TASImage::FromGLBuffer(UChar_t* buf, UInt_t w, UInt_t h)
////////////////////////////////////////////////////////////////////////////////
/// Creates an image from a RGBA buffer

void TASImage::FromBitmap(const UChar_t *buf, UInt_t width, UInt_t height)
void TASImage::FromBitmap(const UChar_t *buf, UInt_t width, UInt_t height, const UChar_t *mask)
{
DestroyImage();
DestroyScaledImage();

fImage = bitmap2asimage(const_cast<unsigned char *>(buf), width, height, 0, nullptr);
fImage = bitmap2asimage(const_cast<unsigned char *>(buf), width, height, 0, const_cast<unsigned char *>(mask));
}


Expand Down
51 changes: 49 additions & 2 deletions graf2d/asimage/src/TASUtils.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,57 @@

#include "TASUtils.h"
#include "RConfigure.h"
#include "TASImage.h"
#include "TVirtualX.h"
#include "TSystem.h"
#include "TVirtualPad.h"
#include "TError.h"


#ifdef NO_ASIMAGE

#include "TImage.h"


Pixmap_t TASUtils::GetPixmap(TImage *)
{
::Error("TASUtils::GetPixmap", "Not implemented, ASImage is not compiled");
return 0;
}

Pixmap_t TASUtils::GetMask(TImage *)
{
::Error("TASUtils::GetMask", "Not implemented, ASImage is not compiled");
return 0;
}

Bool_t TASUtils::PaintImage(TImage *, Drawable_t, Int_t, Int_t, Bool_t)
{
::Error("TASUtils::PaintImage", "Not implemented, ASImage is not compiled");
return kFALSE;
}

Bool_t TASUtils::FillImageFromWindow(TImage *, Window_t, Int_t, Int_t)
{
::Error("TASUtils::FillImageFromWindow", "Not implemented, ASImage is not compiled");
return kFALSE;
}

std::unique_ptr<TImage> TASUtils::FromWindow(Window_t)
{
::Error("TASUtils::FromWindow", "Not implemented, ASImage is not compiled");
return nullptr;
}

std::unique_ptr<TImage> TASUtils::FromPixmap(Pixmap_t, Pixmap_t)
{
::Error("TASUtils::FromPixmap", "Not implemented, ASImage is not compiled");
return nullptr;
}

#else // NO_ASIMAGE

#include "TASImage.h"

#ifdef WIN32
#define X_DISPLAY_MISSING 1
#include "Windows4root.h"
Expand Down Expand Up @@ -250,7 +295,7 @@ std::unique_ptr<TImage> TASUtils::FromPixmap(Pixmap_t pxm, Pixmap_t mask)

unsigned char *mask_bits = mask ? gVirtualX->GetColorBits(mask, 0, 0, w, h) : nullptr;

asimg->fImage = bitmap2asimage(bits, w, h, 0, mask_bits);
asimg->FromBitmap(bits, w, h, mask_bits);

if (mask_bits)
delete [] mask_bits;
Expand Down Expand Up @@ -341,3 +386,5 @@ Bool_t TASUtils::PaintImage(TImage *timg, Drawable_t wid, Int_t x, Int_t y, Bool

return res;
}

#endif // NO_ASIMAGE
2 changes: 1 addition & 1 deletion graf2d/graf/inc/TImage.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ friend TImage operator/(const TImage &i1, const TImage &s2);


// Create an image from bitmap. (See TASImage::FromBitmap)
virtual void FromBitmap(const UChar_t * /*buf*/, UInt_t /*w*/, UInt_t /*h*/) {}
virtual void FromBitmap(const UChar_t * /*buf*/, UInt_t /*w*/, UInt_t /*h*/, const UChar_t * /* mask */ = nullptr) {}

// Create an image from the given pad. (See TASImage::FromPad)
virtual void FromPad(TVirtualPad * /*pad*/, Int_t /*x*/ = 0, Int_t /*y*/ = 0, UInt_t /*w*/ = 0, UInt_t /*h*/ = 0) {}
Expand Down
7 changes: 1 addition & 6 deletions graf2d/padpainter/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,8 @@ ROOT_STANDARD_LIBRARY_PACKAGE(ROOTPadPainter
-writeEmptyRootPCM
DEPENDENCIES
Gpad
ASImageUtils
)


if(asimage)
target_link_libraries(ROOTPadPainter PUBLIC ASImageUtils)
target_compile_definitions(ROOTPadPainter PRIVATE USE_ASIMAGEUTILS)
endif()


ROOT_INSTALL_HEADERS()
23 changes: 2 additions & 21 deletions graf2d/padpainter/src/TPadPainter.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "TPadPainter.h"
#include "TVirtualX.h"
#include "TSystem.h"
#include "TASUtils.h"
#include "TCanvas.h"
#include "TPoint.h"
#include "TError.h"
Expand All @@ -25,10 +26,6 @@
#include "TMath.h"
#include "TPad.h"

#ifdef USE_ASIMAGEUTILS
#include "TASUtils.h"
#endif

namespace {

//Typedef is fine, but let's pretend we look cool and modern:
Expand Down Expand Up @@ -234,17 +231,9 @@ void TPadPainter::DrawImage(TImage *img, Int_t x, Int_t y, Int_t flags)

// use old API to draw image on gVirtualX window
// img->PaintImage(wid, x, y, 0, 0, 0, 0, flags ? "" : "opaque");
#ifdef USE_ASIMAGEUTILS

// new API invokes
TASUtils::PaintImage(img, wid, x, y, !flags);
#else
::Error("TPadPainter::DrawImage", "TASImage not compiled, image painting is not possible");
Comment thread
linev marked this conversation as resolved.
Resolved
(void) wid;
(void) img;
(void) x;
(void) y;
(void) flags;
#endif
}

////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -596,22 +585,14 @@ Bool_t TPadPainter::FillImageFromPad(TImage *image, TVirtualPad *pad) const
if (!image || !pad)
return kFALSE;

#ifdef USE_ASIMAGEUTILS
auto width = pad->GetPadWidth();
auto height = pad->GetPadHeight();

Int_t wid = (pad == pad->GetCanvas()) ? pad->GetCanvasID() : pad->GetPixmapID();
gVirtualX->SelectWindow(wid);

Window_t wd = gVirtualX->GetCurrentWindow();

return TASUtils::FillImageFromWindow(image, wd, width, height);
#else
::Error("TPadPainter::FillImageFromPad", "Cannot work without TASImage class");
(void) image;
(void) pad;
return kFALSE;
#endif
}

//Aux. private functions.
Expand Down
Loading