Josu Onandia wrote:
I would like to 'gray' the screen, as in Windows when you shut-down. Can anyone suggest an efficient way to do this?.
What about ANDing the screen with a pattern of alternating bits?
Hope this helps,
Peter
Thank you, Peter. It works perfectly. But now I've run into another problem: I'm applying the pixmap to a SubContext, not to the whole screen. It seems that the function GrPatternFilledBox doesn´t take this into account, and starts painting at left corner of the screen, not of the SubContext.
I suspect that the line (file patfbox.c, function GrPatternFilledBox):
(*bltfun)( &CURC->gc_frame,xpos,y1, &p->gp_pxp_source,xcuroff,yoff,fillw,fillh, p->gp_pxp_oper );
should be:
(*bltfun)( &CURC->gc_frame, xpos+CURC->gc_xoffset, //adding the subcontext offset y1+CURC->gc_yoffset, //adding the subcontext offset &p->gp_pxp_source,xcuroff,yoff,fillw,fillh, p->gp_pxp_oper );
I've implemented the change, and it works. I wonder if it's a bug or it's something else I'm doing wrong.
Josu
Still looking for bug reports and suggested patches I found this on the grx list:
Thank you, Peter. It works perfectly. But now I've run into another problem: I'm applying the pixmap to a SubContext, not to the whole screen. It seems that the function GrPatternFilledBox doesnŽt take this into account, and starts painting at left corner of the screen, not of the SubContext.
I suspect that the line (file patfbox.c, function GrPatternFilledBox):
(*bltfun)( &CURC->gc_frame,xpos,y1, &p->gp_pxp_source,xcuroff,yoff,fillw,fillh, p->gp_pxp_oper );
should be:
(*bltfun)( &CURC->gc_frame, xpos+CURC->gc_xoffset, //adding the
subcontext offset y1+CURC->gc_yoffset, //adding the subcontext offset &p->gp_pxp_source,xcuroff,yoff,fillw,fillh, p->gp_pxp_oper );
I've implemented the change, and it works. I wonder if it's a bug or it's something else I'm doing wrong.
Well, it looks like most of the pattern stuff should be fixed this way.
Anyone out there who could implement a checking tool for GRX for subcontext support ? Im thinking about something like:
create memory context (eg. 200x200x8bpp) apply some GRX drawing functions (keep a 10 pixel border !) Check 1: border must be clear create a sub context (180x180x8bpp) redo the drawing functions in the sub context using black Check 2: original context should be cleared now
Hartmut
Hartmut Schirmer escribió:
Anyone out there who could implement a checking tool for GRX for subcontext support ? Im thinking about something like:
create memory context (eg. 200x200x8bpp) apply some GRX drawing functions (keep a 10 pixel border !) Check 1: border must be clear create a sub context (180x180x8bpp) redo the drawing functions in the sub context using black Check 2: original context should be cleared now
Here, there is:
-------------------- /** ** SBCTEST.C ---- test subcontext ** **/
#include <string.h> #include "test.h"
TESTFUNC(sbctest) { char bits[] = {0, 76, 50, 0, 0, 76, 60, 0}; GrContext *grc, *grsc; GrPattern *pat1, *pat2;
grc = GrCreateContext( 300,300,NULL,NULL ); if( grc == NULL ) return; grsc = GrCreateSubContext( 10,10,280,280,grc,NULL ); if( grsc == NULL ) return; pat1 = GrBuildPixmapFromBits( bits,8,8,GrWhite(),GrBlack() ); if( pat1 == NULL ) return; pat2 = GrBuildPixmapFromBits( bits,8,8,GrBlack(),GrWhite() ); if( pat2 == NULL ) return;
GrBox( 19,19,320,320,GrWhite() );
GrTextXY( 0,0,"White drawing on context ",GrWhite(),GrBlack() ); GrSetContext( grc ); GrClearContext( GrBlack() ); drawing( 10,10,280,280,GrWhite(),GrNOCOLOR ); GrSetContext( NULL ); GrBitBlt( NULL,20,20,grc,0,0,299,299,GrWRITE ); getch();
GrTextXY( 0,0,"Black drawing on subcontext ",GrWhite(),GrBlack() ); GrSetContext( grsc ); drawing( 0,0,280,280,GrBlack(),GrNOCOLOR ); GrSetContext( NULL ); GrBitBlt( NULL,20,20,grc,0,0,299,299,GrWRITE ); getch();
GrTextXY( 0,0,"Pattern box on context ",GrWhite(),GrBlack() ); GrSetContext( grc ); GrClearContext( GrBlack() ); GrPatternFilledBox( 10,10,289,289,pat1 ); GrSetContext( NULL ); GrBitBlt( NULL,20,20,grc,0,0,299,299,GrWRITE ); getch();
GrTextXY( 0,0,"Pattern box on subcontext ",GrWhite(),GrBlack() ); GrSetContext( grsc ); GrPatternFilledBox( 0,0,279,279,pat2 ); GrSetContext( NULL ); GrBitBlt( NULL,20,20,grc,0,0,299,299,GrWRITE ); getch();
GrDestroyPattern( pat2 ); GrDestroyPattern( pat1 ); GrDestroyContext( grsc ); GrDestroyContext( grc ); } ---------------
And here, a new version of my test programs launcher, with a nice moving text banner.
http://teleline.terra.es/personal/malfer/zipfiles/demgrx11.zip
I know you don´t have enought time to maintain GRX, so what do you think about the GRX future.
Grettings, M.Alvarez
On Tue, 02 May 2000, Mariano Alvarez Fernández wrote:
Hartmut Schirmer escribió:
Anyone out there who could implement a checking tool for GRX for subcontext support ? Im thinking about something like:
[...]
Here, there is:
/** ** SBCTEST.C ---- test subcontext ** **/
Many thanks !
I tried it and found that subcontext and pattern filling is broken.
Several functions are called with (sub-) context coordinates and also with base context coords internally.
Hartmut
Hartmut Schirmer escribió:
On Tue, 02 May 2000, Mariano Alvarez Fernández wrote:
Hartmut Schirmer escribió:
Anyone out there who could implement a checking tool for GRX for subcontext support ? Im thinking about something like:
[...]
Here, there is:
/** ** SBCTEST.C ---- test subcontext ** **/
Many thanks !
I tried it and found that subcontext and pattern filling is broken.
Several functions are called with (sub-) context coordinates and also with base context coords internally.
I don't have the skills to fix the library, but I can extend the test to other functions if you tell me which ones.
Grettings, M.Alvarez
I tried it and found that subcontext and pattern filling is broken.
Several functions are called with (sub-) context coordinates and also with base context coords internally.
I don't have the skills to fix the library, but I can extend the test to other functions if you tell me which ones.
Well, you tracked down some hidden bugs in the past and your patches are ok. Should be sufficent to fix these problems.
All GrPatterned* and GrPatternFill* functions should be checked (and documented).
Major problems are: - Several functions donŽt apply subcontext transformation when drawing - Functions used for a filler-tripple internally shouldnŽt apply the subcontext transformation when drawing, we may call a driver func here, but must apply the transformation to align the pattern.
Eg. in src/pattern/patfline.c the func GrPatternFilledLine() is a user function ( -> apply subcontext offset) and a filler: patternf.c / _GrDrawPatternedLine() -> _GrPatternFilledLine () -> GrPatternFilledLine()
Hartmut
Hartmut Schirmer escribió:
I don't have the skills to fix the library, but I can extend the test to other functions if you tell me which ones.
Well, you tracked down some hidden bugs in the past and your patches are ok. Should be sufficent to fix these problems.
Sorry, I think you are speaking about Josu Onaindia patches.
All GrPatterned* and GrPatternFill* functions should be checked (and documented).
I will do.
M.Alvarez
On Tue, 09 May 2000, Mariano Alvarez Fernández wrote:
Hartmut Schirmer escribió:
I don't have the skills to fix the library, but I can extend the test to other functions if you tell me which ones.
Well, you tracked down some hidden bugs in the past and your patches are ok. Should be sufficent to fix these problems.
Sorry, I think you are speaking about Josu Onaindia patches.
OOPS, sorry. GRX seems to be popular in spain !
Hartmut
Hartmut Schirmer escribió:
All GrPatterned* and GrPatternFill* functions should be checked
I have checked all, and there are only three buggy functions:
GrPatternFilledBox GrPatternFilledLine GrPatternFilledPlot
A question, what the GrPatternDrawStringExt is for?
Here is the test program:
------- /** ** SBCTEST.C ---- test subcontext ** **/
#include <string.h> #include "test.h"
static void drawpf( int border, GrPattern *pat ); static void drawp( int border, GrLinePattern *grlp );
TESTFUNC(sbctest) { char bits[] = {0, 76, 50, 0, 0, 76, 60, 0}; GrContext *grc, *grsc; GrPattern *pat1, *pat2; GrLineOption grl; GrLinePattern grlp; GrFont *grf; GrTextOption grt;
grc = GrCreateContext( 300,300,NULL,NULL ); if( grc == NULL ) return; grsc = GrCreateSubContext( 10,10,290,290,grc,NULL ); if( grsc == NULL ) return; pat1 = GrBuildPixmapFromBits( bits,8,8,GrWhite(),GrBlack() ); if( pat1 == NULL ) return; pat2 = GrBuildPixmapFromBits( bits,8,8,GrBlack(),GrWhite() ); if( pat2 == NULL ) return; grf = GrLoadFont( "lucb40.fnt" ); if( grf == NULL ) return;
GrBox( 19,19,320,320,GrWhite() );
GrTextXY( 0,0,"White drawing on context ",GrWhite(),GrBlack() ); GrSetContext( grc ); GrClearContext( GrBlack() ); drawing( 10,10,280,280,GrWhite(),GrNOCOLOR ); GrSetContext( NULL ); GrBitBlt( NULL,20,20,grc,0,0,299,299,GrWRITE ); getch();
GrTextXY( 0,0,"Black drawing on subcontext ",GrWhite(),GrBlack() ); GrSetContext( grsc ); drawing( 0,0,280,280,GrBlack(),GrNOCOLOR ); GrSetContext( NULL ); GrBitBlt( NULL,20,20,grc,0,0,299,299,GrWRITE ); getch();
GrTextXY( 0,0,"Pattern drawing on context ",GrWhite(),GrBlack() ); GrSetContext( grc ); GrClearContext( GrBlack() ); drawpf( 10,pat1 ); GrSetContext( NULL ); GrBitBlt( NULL,20,20,grc,0,0,299,299,GrWRITE ); getch();
GrTextXY( 0,0,"Pattern drawing on subcontext ",GrWhite(),GrBlack() ); GrSetContext( grsc ); GrClearContext( GrBlack() ); drawpf( 0,pat2 ); GrSetContext( NULL ); GrBitBlt( NULL,20,20,grc,0,0,299,299,GrXOR ); getch();
grl.lno_color = GrWhite(); grl.lno_width = 3; grl.lno_pattlen = 0; grlp.lnp_pattern = pat1; grlp.lnp_option = &grl;
GrTextXY( 0,0,"Patterned drawing on context ",GrWhite(),GrBlack() ); GrSetContext( grc ); GrClearContext( GrBlack() ); grlp.lnp_pattern = pat1; drawp( 10,&grlp ); GrSetContext( NULL ); GrBitBlt( NULL,20,20,grc,0,0,299,299,GrWRITE ); getch();
GrTextXY( 0,0,"Patterned drawing on subcontext",GrWhite(),GrBlack() ); GrSetContext( grsc ); GrClearContext( GrBlack() ); grlp.lnp_pattern = pat2; drawp( 0,&grlp ); GrSetContext( NULL ); GrBitBlt( NULL,20,20,grc,0,0,299,299,GrXOR ); getch();
grt.txo_fgcolor.v = GrWhite(); grt.txo_bgcolor.v = GrBlack() | GrOR; grt.txo_font = grf; grt.txo_direct = GR_TEXT_RIGHT; grt.txo_xalign = GR_ALIGN_LEFT; grt.txo_yalign = GR_ALIGN_CENTER; grt.txo_chrtype = GR_BYTE_TEXT;
GrTextXY( 0,0,"Patterned text on context ",GrWhite(),GrBlack() ); GrSetContext( grc ); GrClearContext( GrBlack() ); GrPatternDrawString( "Hello all",9,20,60,&grt,pat1 ); GrPatternDrawChar( 'G',20,120,&grt,pat1 ); GrPatternDrawStringExt( "Hola a todos",12,20,180,&grt,pat1 ); GrSetContext( NULL ); GrBitBlt( NULL,20,20,grc,0,0,299,299,GrWRITE ); getch();
GrTextXY( 0,0,"Patterned text on subcontext ",GrWhite(),GrBlack() ); GrSetContext( grsc ); GrClearContext( GrBlack() ); GrPatternDrawString( "Hello all",9,10,50,&grt,pat2 ); GrPatternDrawChar( 'G',10,110,&grt,pat2 ); GrPatternDrawStringExt( "Hola a todos",12,10,170,&grt,pat2 ); GrSetContext( NULL ); GrBitBlt( NULL,20,20,grc,0,0,299,299,GrXOR ); getch();
GrUnloadFont( grf ); GrDestroyPattern( pat2 ); GrDestroyPattern( pat1 ); GrDestroyContext( grsc ); GrDestroyContext( grc ); }
/***/
static void drawpf( int border, GrPattern *pat ) { int pt1[4][2] = {{130,200},{140,240},{150,250},{160,180}}; int pt2[4][2] = {{230,200},{235,240},{246,250},{258,180}}; int ptaux[4][2]; int i,j;
GrPatternFilledBox( 0+border,0+border,93+border,93+border,pat ); GrPatternFilledCircle( 139+border,46+border,45,pat ); GrPatternFilledEllipse( 232+border,46+border,45,35,pat ); GrPatternFilledCircleArc( 46+border,139+border,45,-300,600, GR_ARC_STYLE_CLOSE2,pat ); GrPatternFilledEllipseArc( 139+border,139+border,45,35,-700,400, GR_ARC_STYLE_CLOSE2,pat ); GrPatternFilledLine( 188+border,139+border,278+border,139+border,pat ); GrPatternFilledPlot( 47+border,228+border,pat ); GrPatternFilledPlot( 47+border,229+border,pat ); GrPatternFilledPlot( 47+border,230+border,pat ); GrPatternFilledPlot( 47+border,231+border,pat ); GrPatternFilledPlot( 47+border,232+border,pat ); for( i=0; i<4; i++ ) for( j=0; j<2; j++ ) ptaux[i][j] = pt1[i][j] + border; GrPatternFilledPolygon( 4,ptaux,pat ); for( i=0; i<4; i++ ) for( j=0; j<2; j++ ) ptaux[i][j] = pt2[i][j] + border; GrPatternFilledConvexPolygon( 4,ptaux,pat ); }
/***/
static void drawp( int border, GrLinePattern *grlp ) { int pt1[4][2] = {{130,200},{140,240},{150,250},{160,180}}; int pt2[4][2] = {{230,200},{235,240},{246,250},{258,180}}; int ptaux[4][2]; int i,j;
GrPatternedBox( 0+border,0+border,93+border,93+border,grlp ); GrPatternedCircle( 139+border,46+border,45,grlp ); GrPatternedEllipse( 232+border,46+border,45,35,grlp ); GrPatternedCircleArc( 46+border,139+border,45,-300,600, GR_ARC_STYLE_CLOSE2,grlp ); GrPatternedEllipseArc( 139+border,139+border,45,35,-700,400, GR_ARC_STYLE_CLOSE2,grlp ); GrPatternedLine( 188+border,139+border,278+border,139+border,grlp ); for( i=0; i<4; i++ ) for( j=0; j<2; j++ ) ptaux[i][j] = pt1[i][j] + border; GrPatternedPolygon( 4,ptaux,grlp ); for( i=0; i<4; i++ ) for( j=0; j<2; j++ ) ptaux[i][j] = pt2[i][j] + border; GrPatternedPolyLine( 4,ptaux,grlp ); }
On Mon, 15 May 2000, Mariano Alvarez Fernández wrote:
Hartmut Schirmer escribió:
All GrPatterned* and GrPatternFill* functions should be checked
I have checked all, and there are only three buggy functions:
GrPatternFilledBox GrPatternFilledLine GrPatternFilledPlot
Thanks !
A question, what the GrPatternDrawStringExt is for?
No, have to look deeper into the sources ...
Hartmut