JX Application Framework
|
#include <JXImage.h>
Public Types | |
enum | State { kLocalStorage , kRemoteStorage } |
![]() | |
enum | FileType { kUnknownType , kGIFType , kPNGType , kJPEGType , kXPMType , kXBMType } |
Public Member Functions | |
JXImage (JXDisplay *display, const JCoordinate width, const JCoordinate height, const JColorID initColor=kJXTransparentColor, const JSize depth=0, const State initState=kRemoteStorage) | |
JXImage (JXDisplay *display, Drawable source) | |
JXImage (JXDisplay *display, Drawable source, const JRect &rect) | |
JXImage (JXDisplay *display, const JConstBitmap &bitmap, const JColorID foreColor=kJXTransparentColor, const JColorID backColor=kJXTransparentColor, const JSize depth=0) | |
JXImage (JXDisplay *display, const JXPM &data) | |
JXImage (const JXImage &source) | |
JXImage (const JXImage &source, const JRect &rect) | |
~JXImage () override | |
JError | WriteXPM (const JString &fileName) const |
virtual JXImage * | Copy () const |
JXDisplay * | GetDisplay () const |
JSize | GetDepth () const |
bool | HasMask () const |
bool | GetMask (JImageMask **mask) const override |
bool | GetMask (JXImageMask **mask) const |
void | SetMask (JXImageMask *mask) |
void | ClearMask () |
void | Draw (const Drawable drawable, JXGC *gc, const JRect &srcRect, const JRect &destRect) const |
JXImagePainter * | CreatePainter () |
JColorID | GetColor (const JCoordinate x, const JCoordinate y) const override |
void | SetColor (const JCoordinate x, const JCoordinate y, const JColorID color) override |
State | GetDefaultState () const |
void | SetDefaultState (const State state) |
void | ConvertToDefaultState () |
State | GetCurrentState () const |
void | ConvertToLocalStorage () |
void | ConvertToRemoteStorage () |
Pixmap | CreatePixmap () const |
XImage * | CreateXImage () const |
unsigned long | GetSystemColor (const JColorID color) const override |
unsigned long | GetSystemColor (const JCoordinate x, const JCoordinate y) const override |
![]() | |
JImage (const JCoordinate width, const JCoordinate height, JColorManager *colorManager) | |
virtual | ~JImage () |
JCoordinate | GetWidth () const |
JCoordinate | GetHeight () const |
JRect | GetBounds () const |
JColorManager * | GetColorManager () const |
JError | WriteGIF (const JString &fileName, const bool compressColorsToFit, const bool interlace=false) const |
JError | WritePNG (const JString &fileName, const bool useTrueColor=true, const bool compressColorsToFit=false, const bool interlace=false) const |
JError | WriteJPEG (const JString &fileName, const bool interlace=false, const int quality=-1) const |
![]() | |
JBroadcaster () | |
virtual | ~JBroadcaster () |
JBroadcaster & | operator= (const JBroadcaster &source) |
bool | HasSenders () const |
JSize | GetSenderCount () const |
bool | HasRecipients () const |
JSize | GetRecipientCount () const |
virtual JString | ToString () const |
template<class T > | |
void | ListenTo (const JBroadcaster *sender, const std::function< void(const T &)> &f) |
Static Public Member Functions | |
static JError | CreateFromFile (JXDisplay *display, const JString &fileName, JXImage **image) |
static JError | CreateFromGIF (JXDisplay *display, const JString &fileName, JXImage **image) |
static JError | CreateFromPNG (JXDisplay *display, const JString &fileName, JXImage **image) |
static JError | CreateFromJPEG (JXDisplay *display, const JString &fileName, JXImage **image) |
static JError | CreateFromXPM (JXDisplay *display, const JXPM &data, JXImage **image) |
static JError | CreateFromXPM (JXDisplay *display, const JString &fileName, JXImage **image) |
![]() | |
static FileType | GetFileType (const JString &fileName) |
Protected Member Functions | |
XImage * | GetImage () const |
void | ConvertToImage () const |
Pixmap | GetPixmap () const |
void | ConvertToPixmap () const |
const JXGC * | GetGC () const |
void | ForcePrivateGC () |
void | SetImageData (const JSize colorCount, const JColorID *colorTable, unsigned short **imageData, const bool hasMask, const unsigned long maskColor) override |
void | PrepareForImageData () override |
void | ImageDataFinished () override |
JXImage (const Pixmap bitmap, const JCoordinate width, const JCoordinate height, JXDisplay *display) | |
![]() | |
JImage (const JImage &source) | |
void | SetDimensions (const JCoordinate width, const JCoordinate height) |
JError | ReadGIF (const JString &fileName) |
JError | ReadPNG (const JString &fileName) |
JError | ReadJPEG (const JString &fileName) |
void | ReadFromJXPM (const JXPM &pixmap) |
![]() | |
JBroadcaster (const JBroadcaster &source) | |
void | ListenTo (const JBroadcaster *sender) |
void | StopListening (const JBroadcaster *sender) |
void | ClearWhenGoingAway (const JBroadcaster *sender, void *pointerToMember) |
void | StopListening (const JBroadcaster *sender, const std::type_info &messageType) |
template<class T > | |
void | Send (JBroadcaster *recipient, const T &message) |
template<class T > | |
void | Broadcast (const T &message) |
virtual void | Receive (JBroadcaster *sender, const Message &message) |
void | SendWithFeedback (JBroadcaster *recipient, Message *message) |
void | BroadcastWithFeedback (Message *message) |
virtual void | ReceiveWithFeedback (JBroadcaster *sender, Message *message) |
virtual void | ReceiveGoingAway (JBroadcaster *sender) |
Friends | |
class | JXWindow |
class | JXImagePainter |
Additional Inherited Members | |
![]() | |
static const JUtf8Byte * | kUnknownFileType = "UnknownFileType::JImage" |
static const JUtf8Byte * | kFileIsNotGIF = "FileIsNotGIF::JImage" |
static const JUtf8Byte * | kGIFNotAvailable = "GIFNotAvailable::JImage" |
static const JUtf8Byte * | kFileIsNotPNG = "FileIsNotPNG::JImage" |
static const JUtf8Byte * | kPNGNotAvailable = "PNGNotAvailable::JImage" |
static const JUtf8Byte * | kFileIsNotJPEG = "FileIsNotJPEG::JImage" |
static const JUtf8Byte * | kJPEGNotAvailable = "JPEGNotAvailable::JImage" |
static const JUtf8Byte * | kFileIsNotXPM = "FileIsNotXPM::JImage" |
static const JUtf8Byte * | kXPMNotAvailable = "XPMNotAvailable::JImage" |
static const JUtf8Byte * | kFileIsNotXBM = "FileIsNotXBM::JImage" |
static const JUtf8Byte * | kTooManyColors = "TooManyColors::JImage" |
![]() | |
static JError | AllocateImageData (const JCoordinate w, const JCoordinate h, unsigned short **data, unsigned short ***cols) |
Class representing an offscreen drawable and XImage. These are combined into a single class because the issue of where the image is stored should be hidden, for convenience. It is, however, *very* expensive to convert an image between a drawable (remote storage) and an XImage (local storage). Therefore, do not interleave GetColor()/SetColor() with drawing commands (via JXImagePainter). Collect them into blocks of calls. (This is usually what one does anyway.) Planned features: For image read from file: store raw rgb values separately and then rewrite JPSPrinter to ask for rgb instead of JColorID.
Image format functions separated out to allow smarter linking.
JPEG functions separated out to allow smarter linking.
PNG functions separated out to allow smarter linking.
enum JXImage::State |
JXImage::JXImage | ( | JXDisplay * | display, |
const JCoordinate | width, | ||
const JCoordinate | height, | ||
const JColorID | origInitColor = kJXTransparentColor , |
||
const JSize | depth = 0 , |
||
const State | initState = kRemoteStorage |
||
) |
initState == kLocalStorage accepts origInitColor=0
JXImage::JXImage | ( | JXDisplay * | display, |
Drawable | source | ||
) |
We assume that the given JXColorManager is the colormap used by the given Drawable. (X does not seem to provide a way to check this because XGetWindowAttributes() only works on a Window, not a Pixmap.) This means that we assume that all the colors used by the Drawable have been registered with the JXColorManager. If we didn't assume this, we would have to call XQueryColor for every pixel and that would be really slow.
This routine can still be slow because we have to analyze the given Drawable and register all the colors that are used.
JXImage::JXImage | ( | JXDisplay * | display, |
const JConstBitmap & | bitmap, | ||
const JColorID | foreColor = kJXTransparentColor , |
||
const JColorID | backColor = kJXTransparentColor , |
||
const JSize | depth = 0 |
||
) |
This only works for XPM's with up to 256 colors.
JXImage::JXImage | ( | const JXImage & | source | ) |
|
override |
|
protected |
This is used by JXImageMask. The depth is assumed to be 1.
void JXImage::ClearMask | ( | ) |
void JXImage::ConvertToDefaultState | ( | ) |
|
protected |
|
inline |
Convert the image to local storage on the client side.
|
protected |
|
inline |
Convert the image to remote storage on the server side.
|
virtual |
We can't support operator= because there are derived classes.
Reimplemented in JXImageMask.
|
static |
Returns an error if the file does not contain a recognizable image format.
|
static |
Returns an error if the file does not contain a GIF.
|
static |
Returns an error if the file does not contain a JPEG.
|
static |
Returns an error if the file does not contain a PNG.
|
static |
Returns an error if the file does not contain an XPM.
JXImagePainter * JXImage::CreatePainter | ( | ) |
Pixmap JXImage::CreatePixmap | ( | ) | const |
The caller is responsible for calling XFreePixmap().
XImage * JXImage::CreateXImage | ( | ) | const |
The caller is responsible for calling XDestroyImage().
void JXImage::Draw | ( | const Drawable | drawable, |
JXGC * | gc, | ||
const JRect & | srcRect, | ||
const JRect & | destRect | ||
) | const |
Copy the specified portion of the image, centered within destRect.
|
protected |
|
overridevirtual |
Implements JImage.
JXImage::State JXImage::GetCurrentState | ( | ) | const |
|
inline |
|
inline |
|
inline |
|
protected |
|
inlineprotected |
|
overridevirtual |
Implements JImage.
|
inline |
|
inlineprotected |
|
overridevirtual |
Implements JImage.
|
overridevirtual |
Implements JImage.
|
inline |
|
overrideprotectedvirtual |
Implements JImage.
|
overrideprotectedvirtual |
Implements JImage.
|
overridevirtual |
In the long run, it is usually more efficient to convert to an XImage once, rather than sending a large number of XDrawPoint() messages to the server.
Implements JImage.
|
inline |
|
overrideprotectedvirtual |
colorTable[ imageData[x][y] ] is the JColorID for pixel (x,y)
colorTable[ maskColor ] is the transparent color, which shouldn't be used
Implements JImage.
void JXImage::SetMask | ( | JXImageMask * | mask | ) |
Returns an error if we are unable to create the specified file.
|
friend |
|
friend |