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
1 change: 1 addition & 0 deletions core/base/inc/TVirtualX.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ class TVirtualX : public TNamed, public TAttLine, public TAttFill, public TAttTe
virtual void DrawPolyMarkerW(WinContext_t wctxt, Int_t n, TPoint *xy);
virtual void DrawTextW(WinContext_t wctxt, Int_t x, Int_t y, Float_t angle, Float_t mgn, const char *text, ETextMode mode);
virtual void DrawTextW(WinContext_t wctxt, Int_t x, Int_t y, Float_t angle, Float_t mgn, const wchar_t *text, ETextMode mode);
virtual Int_t WriteGIFW(WinContext_t wctxt, const char *name);


//---- OpenGL related stuff, required only with R__HAS_COCOA ----
Expand Down
8 changes: 8 additions & 0 deletions core/base/src/TVirtualX.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,14 @@ void TVirtualX::DrawTextW(WinContext_t /* wctxt */, Int_t x, Int_t y, Float_t an
DrawText(x, y, angle, mgn, text, mode);
}

////////////////////////////////////////////////////////////////////////////////
/// Save specified window as GIF image

Int_t TVirtualX::WriteGIFW(WinContext_t /* wctxt */, const char *name)
{
return WriteGIF((char *) name);
}

////////////////////////////////////////////////////////////////////////////////
/// Executes the command "code" coming from the other threads (Win32)

Expand Down
23 changes: 16 additions & 7 deletions graf2d/asimage/src/TASImage.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -2231,8 +2231,6 @@ Bool_t TASImage::InitVisual()
if (fgVisual && (noX == fgBatch))
return kTRUE;

if (fgVisual)
destroy_asvisual(fgVisual, kFALSE);
fgVisual = nullptr;
fgBatch = false;

Expand All @@ -2244,16 +2242,27 @@ Bool_t TASImage::InitVisual()
Visual *vis = (Visual*) gVirtualX->GetVisual();
Colormap cmap = (Colormap) gVirtualX->GetColormap();

if (vis && cmap)
fgVisual = create_asvisual_for_id(disp, screen, depth,
static ASVisual *vis_x = nullptr;

if (vis && cmap && !noX) {
if (!vis_x)
vis_x = create_asvisual_for_id(disp, screen, depth,
XVisualIDFromVisual(vis), cmap, nullptr);
fgVisual = vis_x;
}
#endif
#endif

static ASVisual *vis_batch = nullptr;

if (!fgVisual) {
// create dummy fgVisual for batch mode
fgVisual = create_asvisual(nullptr, 0, 0, nullptr);
fgVisual->dpy = nullptr; // fake (not used)
if (!vis_batch) {
// create dummy visual for batch mode
vis_batch = create_asvisual(nullptr, 0, 0, nullptr);
vis_batch->dpy = nullptr; // fake (not used)
}

fgVisual = vis_batch;
fgBatch = true;
}

Expand Down
7 changes: 7 additions & 0 deletions graf2d/gifencode/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# gifencode and gifdecode

Originally it was plain C code to create GIF images from pixmap
and read GIF images to create new pixmap

Later C++ interface was provided to exclude static variables usage

58 changes: 24 additions & 34 deletions graf2d/x11/src/gifdecode.c → graf2d/gifencode/gifdecode.cxx
Original file line number Diff line number Diff line change
@@ -1,46 +1,32 @@
/* @(#)root/x11:$Id$ */
/* Author: Rene Brun 11/06/97*/
#include <stdio.h>
#include <string.h>
/* Author: Rene Brun 11/06/97 */
/* C++ interface Sergey Linev 21/04/2026 */

#include "gifdecode.h"

#define BITS 12 /* largest code size */
#define TSIZE 4096 /* tables size */

typedef unsigned char byte;
#include <cstdio>
#include <cstring>

static int Prefix[TSIZE]; /* prefix table */
static byte Suffix[TSIZE]; /* suffix table */
static byte OutCode[TSIZE]; /* output stack */

static byte *ptr1, /* pointer to GIF array */
*ptr2; /* pointer to PIX array */

static int CurCodeSize, /* current number of bits per code */
CurMaxCode; /* maximum code, given CurCodeSize */

static long CurBit; /* current bit in GIF image data */
#define BITS 12 /* largest code size */
#define TSIZE 4096 /* tables size */

/***************************************************************
* *
***************************************************************/
static int ReadCode()
int TGifDecode::ReadCode()
{
static long b3[3], CurByte;
static byte lblk;
int shift, nbyte;
long OldByte;

if (CurBit == -1) {
lblk = 0;
CurByte = -1;
}

CurBit += CurCodeSize;
OldByte = CurByte;
long OldByte = CurByte;
CurByte = CurBit/8;
nbyte = CurByte - OldByte;
shift = 17 + (CurBit%8) - CurCodeSize;
int nbyte = CurByte - OldByte;
int shift = 17 + (CurBit%8) - CurCodeSize;
while (nbyte-- > 0) {
if (lblk == 0) {
lblk = *ptr1++;
Expand All @@ -57,7 +43,7 @@ static int ReadCode()
/***************************************************************
* *
***************************************************************/
static void OutPixel(byte pix)
void TGifDecode::OutPixel(unsigned char pix)
{
*ptr2++ = pix;
}
Expand All @@ -77,15 +63,15 @@ static void OutPixel(byte pix)
* 1 - if error *
* *
***************************************************************/
int GIFinfo(byte *GIFarr, int *Width, int *Height, int *Ncols)
int TGifDecode::GIFinfo(unsigned char *GIFarr, int *Width, int *Height, int *Ncols)
{
byte b;
unsigned char b;

ptr1 = GIFarr;
unsigned char *ptr1 = GIFarr;

/* R E A D H E A D E R */

if (strncmp((char *)GIFarr,"GIF87a",6) && strncmp((char *)GIFarr,"GIF89a",6))
if (strncmp((const char *)GIFarr,"GIF87a",6) && strncmp((const char *)GIFarr,"GIF89a",6))
{
fprintf(stderr,"\nGIFinfo: not a GIF\n");
return 1;
Expand Down Expand Up @@ -146,9 +132,9 @@ int GIFinfo(byte *GIFarr, int *Width, int *Height, int *Ncols)
* 1 - if error *
* *
***************************************************************/
int GIFdecode(byte *GIFarr, byte *PIXarr, int *Width, int *Height, int *Ncols, byte *R, byte *G, byte *B)
int TGifDecode::GIFdecode(unsigned char *GIFarr, unsigned char *PIXarr, int *Width, int *Height, int *Ncols, unsigned char *R, unsigned char *G, unsigned char *B)
{
byte b, /* working variable */
unsigned char b, /* working variable */
FinChar; /* final character */

int i, /* working variable for loops */
Expand All @@ -165,6 +151,10 @@ int GIFdecode(byte *GIFarr, byte *PIXarr, int *Width, int *Height, int *Ncols, b

long Npix; /* number of pixels */

int Prefix[TSIZE]; /* prefix table */
unsigned char Suffix[TSIZE]; /* suffix table */
unsigned char OutCode[TSIZE]; /* output stack */

ptr1 = GIFarr;
ptr2 = PIXarr;
OldCode = 0;
Expand Down Expand Up @@ -271,8 +261,8 @@ int GIFdecode(byte *GIFarr, byte *PIXarr, int *Width, int *Height, int *Ncols, b
fprintf(stderr,"\nGIFdecode: corrupted GIF (big output count)\n");
return 1;
}
OutCode[OutCount++] = Suffix[CurCode];
CurCode = Prefix[CurCode];
OutCode[OutCount++] = Suffix[CurCode];
CurCode = Prefix[CurCode];
}
FinChar = CurCode;
OutCode[OutCount++] = FinChar;
Expand Down
33 changes: 33 additions & 0 deletions graf2d/gifencode/gifdecode.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/* @(#)root/x11:$Id$ */
/* Author: S.Linev 20/04/2026 */
/* C++ interface for gifdecode.c */

#ifndef gifdecode_h
#define gifdecode_h

class TGifDecode {
private:
unsigned char *ptr1 = nullptr; /* pointer to GIF array */
unsigned char *ptr2 = nullptr; /* pointer to PIX array */

int CurCodeSize = 0; /* current number of bits per code */
int CurMaxCode = 0; /* maximum code, given CurCodeSize */
long CurBit = -1; /* current bit in GIF image data */

long b3[3] = {0, 0, 0};
long CurByte = -1;
unsigned char lblk = 0;

int ReadCode();
void OutPixel(unsigned char pix);

public:

static int GIFinfo(unsigned char *GIFarr, int *Width, int *Height, int *Ncols);

int GIFdecode(unsigned char *GIFarr, unsigned char *PIXarr, int *Width, int *Height, int *Ncols, unsigned char *R, unsigned char *G, unsigned char *B);

};


#endif
Loading
Loading