"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/foxhacks.cpp" between
xfe-1.42.tar.gz and xfe-1.43.tar.gz

About: Xfe (X File Explorer) is a file manager and browser (using the FOX toolkit).

foxhacks.cpp  (xfe-1.42):foxhacks.cpp  (xfe-1.43)
skipping to change at line 3615 skipping to change at line 3615
// !!! End of hack // !!! End of hack
length(n); length(n);
len = vsprintf(str, fmt, args); len = vsprintf(str, fmt, args);
FXASSERT(0 <= len && len <= n); FXASSERT(0 <= len && len <= n);
} }
length(len); length(len);
return(*this); return(*this);
} }
//
// Hack of FXIcon
// This hack fixes a Valgrind complaint about uninitialized values
// when allocating an icon
//
#define DARKCOLOR(r,g,b) (((r)+(g)+(b))<thresh)
// Determine threshold for etch mask
static FXshort guessthresh(const FXColor *data,FXint width,FXint height)
{
register FXint med=(width*height)>>1;
register FXint cum,i,j;
register FXshort guess;
FXint frequency[766];
memset(frequency,0,sizeof(frequency));
for(i=0; i<width*height; ++i)
{
frequency[((const FXuchar*)(data+i))[0]+((const FXuchar*)(data+i))[1]+((
const FXuchar*)(data+i))[2]]++;
}
for(i=0,cum=0; i<766; ++i)
{
if((cum+=frequency[i])>=med) break;
}
for(j=765,cum=0; j>0; --j)
{
if((cum+=frequency[j])>=med) break;
}
guess=((i+j+1)>>1)+1; // Fanglin Zhu: raise threshold by one in case of sing
le-color image
return guess;
}
// Render icon X Windows
void FXIcon::render()
{
if(xid)
{
register Visual *vis;
register XImage *xim=NULL;
register FXColor *img;
register FXint x,y;
register FXshort thresh; // Local variable in 1.6
XGCValues values;
GC gc;
// Render the image pixels
FXImage::render();
// Fill with pixels if there is data
if(data && 0<width && 0<height)
{
// Guess threshold
thresh=guessthresh(data,width,height);
// Get Visual
vis=(Visual*)visual->visual;
// Try create image
xim=XCreateImage(DISPLAY(getApp()),vis,1,ZPixmap,0,NULL,width,height
,32,0);
if(!xim) fxerror("%s::render: unable to render icon.\n",getClassName
());
// Try create temp pixel store
// !!! Hack here => replace FXMALLOC with FXCALLOC !!!
if(!FXCALLOC(&xim->data,char,xim->bytes_per_line*height)){ fxerror("
%s::render: unable to allocate memory.\n",getClassName()); }
// !!! End of hack !!!
// Make GC
values.foreground=0xffffffff;
values.background=0xffffffff;
gc=XCreateGC(DISPLAY(getApp()),shape,GCForeground|GCBackground,&valu
es);
// Should have succeeded
FXASSERT(xim);
// Fill shape mask
if(options&IMAGE_OPAQUE) // Opaque
image
{
FXTRACE((150,"Shape rectangle\n"));
memset(xim->data,0xff,xim->bytes_per_line*height);
}
else if(options&(IMAGE_ALPHACOLOR|IMAGE_ALPHAGUESS)) // Transpa
rent color
{
FXTRACE((150,"Shape from alpha-color\n"));
img=data;
for(y=0; y<height; y++)
{
for(x=0; x<width; x++)
{
XPutPixel(xim,x,y,(img[x]!=transp));
}
img+=width;
}
}
else // Transpa
rency channel
{
FXTRACE((150,"Shape from alpha-channel\n"));
img=data;
for(y=0; y<height; y++)
{
for(x=0; x<width; x++)
{
XPutPixel(xim,x,y,(((FXuchar*)(img+x))[3]!=0));
}
img+=width;
}
}
XPutImage(DISPLAY(getApp()),shape,gc,xim,0,0,0,0,width,height);
// Fill etch image
if(options&IMAGE_OPAQUE) // Opaque
image
{
img=data;
for(y=0; y<height; y++)
{
for(x=0; x<width; x++)
{
XPutPixel(xim,x,y,DARKCOLOR(((FXuchar*)(img+x))[0],((FXu
char*)(img+x))[1],((FXuchar*)(img+x))[2]));
}
img+=width;
}
}
else if(options&(IMAGE_ALPHACOLOR|IMAGE_ALPHAGUESS)) // Transpa
rent color
{
img=data;
for(y=0; y<height; y++)
{
for(x=0; x<width; x++)
{
XPutPixel(xim,x,y,(img[x]!=transp) && DARKCOLOR(((FXucha
r*)(img+x))[0],((FXuchar*)(img+x))[1],((FXuchar*)(img+x))[2]));
}
img+=width;
}
}
else // Transpa
rency channel
{
img=data;
for(y=0; y<height; y++)
{
for(x=0; x<width; x++)
{
XPutPixel(xim,x,y,(((FXuchar*)(img+x))[3]!=0) && DARKCOL
OR(((FXuchar*)(img+x))[0],((FXuchar*)(img+x))[1],((FXuchar*)(img+x))[2]));
}
img+=width;
}
}
// Transfer image
XPutImage(DISPLAY(getApp()),etch,gc,xim,0,0,0,0,width,height);
// Clean up
FXFREE(&xim->data);
XDestroyImage(xim);
XFreeGC(DISPLAY(getApp()),gc);
}
}
}
 End of changes. 1 change blocks. 
0 lines changed or deleted 0 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)