From: <hba...@us...> - 2010-09-21 23:01:31
|
Revision: 11194 http://plplot.svn.sourceforge.net/plplot/?rev=11194&view=rev Author: hbabcock Date: 2010-09-21 23:01:24 +0000 (Tue, 21 Sep 2010) Log Message: ----------- Add Alpha value support for plotting in memory. Tested that this does not break the mem or memcairo drivers. Memcairo plotting with alpha values has not yet been tested. Modified Paths: -------------- trunk/drivers/cairo.c trunk/include/plplot.h trunk/include/plstrm.h trunk/src/plcore.c Modified: trunk/drivers/cairo.c =================================================================== --- trunk/drivers/cairo.c 2010-09-18 23:04:08 UTC (rev 11193) +++ trunk/drivers/cairo.c 2010-09-21 23:01:24 UTC (rev 11194) @@ -2389,6 +2389,7 @@ pls->xlength = pls->phyxma; pls->ylength = pls->phyyma; + /* Setup the PLStream and the font lookup table */ aStream = stream_and_font_setup( pls, 0 ); @@ -2424,6 +2425,7 @@ /* 32 bit word order * cairo mem: Big endian: 0=A, 1=R, 2=G, 3=B * Little endian: 3=A, 2=R, 1=G, 0=B */ + if ( aStream->bigendian ) { for ( i = 0; i < ( pls->xlength * pls->ylength ); i++ ) @@ -2431,8 +2433,14 @@ cairo_mem[1] = input_mem[0]; /* R */ cairo_mem[2] = input_mem[1]; /* G */ cairo_mem[3] = input_mem[2]; /* B */ - input_mem += 3; - cairo_mem += 4; + if ( pls->dev_mem_alpha ){ + cairo_mem[0] = input_mem[3]; + input_mem += 4; + } + else { + input_mem += 3; + } + cairo_mem += 4; } } else @@ -2442,8 +2450,14 @@ cairo_mem[2] = input_mem[0]; /* R */ cairo_mem[1] = input_mem[1]; /* G */ cairo_mem[0] = input_mem[2]; /* B */ - input_mem += 3; - cairo_mem += 4; + if ( pls->dev_mem_alpha ){ + cairo_mem[3] = input_mem[3]; + input_mem += 4; + } + else { + input_mem += 3; + } + cairo_mem += 4; } } @@ -2492,7 +2506,13 @@ memory[0] = cairo_surface_data[1]; /* R */ memory[1] = cairo_surface_data[2]; /* G */ memory[2] = cairo_surface_data[3]; /* B */ - memory += 3; + if ( pls->dev_mem_alpha ){ + memory[3] = cairo_surface_data[0]; + memory += 4; + } + else { + memory += 3; + } cairo_surface_data += 4; } } @@ -2503,7 +2523,13 @@ memory[0] = cairo_surface_data[2]; /* R */ memory[1] = cairo_surface_data[1]; /* G */ memory[2] = cairo_surface_data[0]; /* B */ - memory += 3; + if ( pls->dev_mem_alpha ){ + memory[3] = cairo_surface_data[3]; + memory += 4; + } + else { + memory += 3; + } cairo_surface_data += 4; } } Modified: trunk/include/plplot.h =================================================================== --- trunk/include/plplot.h 2010-09-18 23:04:08 UTC (rev 11193) +++ trunk/include/plplot.h 2010-09-21 23:01:24 UTC (rev 11194) @@ -751,6 +751,7 @@ #define plslabelfunc c_plslabelfunc #define plsmaj c_plsmaj #define plsmem c_plsmem +#define plsmema c_plsmema #define plsmin c_plsmin #define plsori c_plsori #define plspage c_plspage Modified: trunk/include/plstrm.h =================================================================== --- trunk/include/plstrm.h 2010-09-18 23:04:08 UTC (rev 11193) +++ trunk/include/plstrm.h 2010-09-21 23:01:24 UTC (rev 11194) @@ -187,6 +187,7 @@ * page PLINT Page count for output stream * linepos PLINT Line count for output stream * pdfs PDFstrm* PDF stream pointer + * dev_mem_alpha PLINT The user supplied memory buffer supports alpha values * * These are used by the escape function (for area fill, etc). * @@ -775,6 +776,7 @@ //CONSTANT SOVERSION FIX PLBOOL stream_closed; PLINT line_style; + PLINT dev_mem_alpha; } PLStream; /*--------------------------------------------------------------------------*\ Modified: trunk/src/plcore.c =================================================================== --- trunk/src/plcore.c 2010-09-18 23:04:08 UTC (rev 11193) +++ trunk/src/plcore.c 2010-09-21 23:01:24 UTC (rev 11194) @@ -3456,9 +3456,20 @@ c_plsmem( PLINT maxx, PLINT maxy, void *plotmem ) { plsc->dev = plotmem; + plsc->dev_mem_alpha = 0; plP_setphy( 0, maxx, 0, maxy ); } +/* Same as plsmem, but the buffer is (Y, X, RGBA) */ + +void +c_plsmema( PLINT maxx, PLINT maxy, void *plotmem ) +{ + plsc->dev = plotmem; + plsc->dev_mem_alpha = 1; + plP_setphy( 0, maxx, 0, maxy ); +} + /* Get the current stream pointer */ void This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |