[PATCH] Formula transparency patch.
"E. Rosten" <[email protected]>
| Newsgroups | gmane.text.doxygen.devel |
|---|---|
| Message-ID | <[email protected]> |
I've attached a patch to render formulas slightly differently. The current
method of rendering is to render the formula to a white background, then output
the exact colour as opaque, except for pure white which is set to fully
transparent.
The new method (attached) renders all non white pixels as pure black, but sets
various levels of transparency to achieve a smooth effect. This ensures that
the equations render correctly if the web browser background is not set to
white.
I haven't quite figured out how to set it up so that it can be switched on with
a configuration option.
To illustrate the method with a rather exxtreme example, I've composited a
sample formula against a dark blue background, and attached the images.
Regards
-Ed
--
(You can't go wrong with psycho-rats.)(http://mi.eng.cam.ac.uk/~er258)
/d{def}def/f{/Times s selectfont}d/s{11}d/r{roll}d f 2/m{moveto}d -1
r 230 350 m 0 1 179{ 1 index show 88 rotate 4 mul 0 rmoveto}for/s 12
d f pop 235 420 translate 0 0 moveto 1 2 scale show showpage
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Doxygen-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/doxygen-develop
smooth-alpha-1.5.9.patch
(text/x-patch, 5.6 KB)
diff -cr doxygen-1.5.9/src/formula.cpp doxygen-1.5.9-smooth-alpha/src/formula.cpp
*** doxygen-1.5.9/src/formula.cpp 2008-10-12 12:53:11.000000000 +0100
--- doxygen-1.5.9-smooth-alpha/src/formula.cpp 2009-09-01 17:54:13.000000000 +0100
***************
*** 272,278 ****
resultName.sprintf("form_%d.png",pageNum);
// the option parameter 1 is used here as a temporary hack
// to select the right color palette!
! dstImage.save(resultName,1);
delete[] data;
}
f.close();
--- 272,278 ----
resultName.sprintf("form_%d.png",pageNum);
// the option parameter 1 is used here as a temporary hack
// to select the right color palette!
! dstImage.save(resultName,2);
delete[] data;
}
f.close();
diff -cr doxygen-1.5.9/src/image.cpp doxygen-1.5.9-smooth-alpha/src/image.cpp
*** doxygen-1.5.9/src/image.cpp 2008-01-01 10:41:07.000000000 +0000
--- doxygen-1.5.9-smooth-alpha/src/image.cpp 2009-09-01 17:25:59.000000000 +0100
***************
*** 173,178 ****
--- 173,217 ----
{ 0x00, 0x00, 0x00 }
};
+ static Color palette3[] =
+ {
+ { 0x00, 0x00, 0x00 },
+ { 0x00, 0x00, 0x00 },
+ { 0x00, 0x00, 0x00 },
+ { 0x00, 0x00, 0x00 },
+ { 0x00, 0x00, 0x00 },
+ { 0x00, 0x00, 0x00 },
+ { 0x00, 0x00, 0x00 },
+ { 0x00, 0x00, 0x00 },
+ { 0x00, 0x00, 0x00 },
+ { 0x00, 0x00, 0x00 },
+ { 0x00, 0x00, 0x00 },
+ { 0x00, 0x00, 0x00 },
+ { 0x00, 0x00, 0x00 },
+ { 0x00, 0x00, 0x00 },
+ { 0x00, 0x00, 0x00 },
+ { 0x00, 0x00, 0x00 }
+ };
+ static Byte palette3_transparency[] =
+ {
+ 0x00,
+ 0x10,
+ 0x20,
+ 0x30,
+ 0x40,
+ 0x50,
+ 0x60,
+ 0x70,
+ 0x80,
+ 0x90,
+ 0xa0,
+ 0xb0,
+ 0xc0,
+ 0xd0,
+ 0xe0,
+ 0xff,
+ };
+
Image::Image(int w,int h)
{
data = new uchar[w*h];
***************
*** 321,331 ****
bool Image::save(const char *fileName,int mode)
{
! PngEncoder enc(data,
! mode==0 ? palette : palette2,
! width,height,
! mode==0 ? 3 : 4,
! 0);
! enc.write(fileName);
return TRUE;
}
--- 360,383 ----
bool Image::save(const char *fileName,int mode)
{
! if(mode == 2)
! {
! PngEncoder enc(data,
! palette3,
! palette3_transparency,
! width,height,
! 4,
! 0);
! enc.write(fileName);
! }
! else
! {
! PngEncoder enc(data,
! mode==0 ? palette : palette2,
! width,height,
! mode==0 ? 3 : 4,
! 0);
! enc.write(fileName);
! }
return TRUE;
}
diff -cr doxygen-1.5.9/src/pngenc.cpp doxygen-1.5.9-smooth-alpha/src/pngenc.cpp
*** doxygen-1.5.9/src/pngenc.cpp 2008-01-01 10:41:08.000000000 +0000
--- doxygen-1.5.9-smooth-alpha/src/pngenc.cpp 2009-09-01 17:23:47.000000000 +0100
***************
*** 46,52 ****
}
PngEncoder::PngEncoder(Byte *rawBytes, Color *p, int w, int h, Byte d, int t) :
! data(rawBytes), palette(p), width(w), height(h), depth(d), transIndex(t)
{
numPixels = w*h;
dataPtr = data;
--- 46,59 ----
}
PngEncoder::PngEncoder(Byte *rawBytes, Color *p, int w, int h, Byte d, int t) :
! data(rawBytes), palette(p), palette_trans(0), width(w), height(h), depth(d), transIndex(t)
! {
! numPixels = w*h;
! dataPtr = data;
! }
!
! PngEncoder::PngEncoder(Byte *rawBytes, Color *p, Byte* tr, int w, int h, Byte d, int t) :
! data(rawBytes), palette(p), palette_trans(tr), width(w), height(h), depth(d), transIndex(t)
{
numPixels = w*h;
dataPtr = data;
***************
*** 110,117 ****
PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE
);
free(png_palette);
! ti[0] = transIndex;
! png_set_tRNS(png_ptr,info_ptr,ti,1,NULL);
rows = (unsigned char **) calloc(sizeof(unsigned char*),height);
rows[0] = (unsigned char *) calloc(sizeof(unsigned char),height*width);
for (i=1; i<height; i++)
--- 117,135 ----
PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE
);
free(png_palette);
!
! //By default, use white as the transparent entry
! if(palette_trans == 0)
! {
! ti[0] = transIndex;
! png_set_tRNS(png_ptr,info_ptr,ti,1,NULL);
! }
! else
! {
! png_set_tRNS(png_ptr,info_ptr,palette_trans, numOfColors ,NULL);
! }
!
!
rows = (unsigned char **) calloc(sizeof(unsigned char*),height);
rows[0] = (unsigned char *) calloc(sizeof(unsigned char),height*width);
for (i=1; i<height; i++)
diff -cr doxygen-1.5.9/src/pngenc.h doxygen-1.5.9-smooth-alpha/src/pngenc.h
*** doxygen-1.5.9/src/pngenc.h 2008-01-01 10:41:01.000000000 +0000
--- doxygen-1.5.9-smooth-alpha/src/pngenc.h 2009-09-01 17:19:30.000000000 +0100
***************
*** 39,44 ****
--- 39,45 ----
{
public:
PngEncoder(Byte *rawBytes,Color *p,int w,int h,Byte d,int t);
+ PngEncoder(Byte *rawBytes,Color *p,Byte* trans, int w,int h,Byte d,int t);
~PngEncoder();
void write(const char *fileName);
***************
*** 46,51 ****
--- 47,53 ----
// image variables
Byte *data; // pointer to the image data (one byte per pixel)
Color *palette; // pointer to the color palette
+ Byte* palette_trans; // pointer to transparency information
int width; // image width
int height; // image height
Byte depth; // bits per CLUT entry
form_new_composited.png
(image/png, 676 B) - not displayed
form_old_composited.png
(image/png, 674 B) - not displayed