Home All Groups Group Topic Archive Search About

Error on Graphics CompositingMode.SourceCopy

Author
8 Mar 2006 9:35 AM
Carlo (MCP only)
Hi all
I need to write some strings on a Graphic surface of a simple control with a
color that is not blend with background color.
To get this, I simply need set CompositingMode to SourceCopy.
This is the code:

   Dim aGraphicSurface As Graphics = CType(mObject,
Control).Parent.CreateGraphics
   aGraphicSurface.CompositingMode = CompositingMode.SourceCopy
   aGraphicSurface.DrawString(mCaptionText, mCaptionFont, _
                              New SolidBrush(mCaptionColor), _
                              mTextRectangle, _
                              mStringFormat)

The above code reises me an ArgumentException (invalid parameter) error.

I cannot understand why the error is raised.
Some additional notes:
DrawImage works correctly.
Removing aGraphicSurface.CompositingMode = CompositingMode.SourceCopy
everything works correctly.
I also tried to set different Alpha levels of mCaptionColor.
I also tried  to change other Graphics setings (such as CompositionQuality,
InterpolationMode, SmoothingMode, TextRenderingHint, ecc.), without results.

Could you please help me?

Thank yuu,

Carlo





-------------------------------------------
Carlo, MCP (Windows Based Applications)
carlodevREM***@gmail.com

Author
8 Mar 2006 11:09 AM
Armin Zingler
Show quote Hide quote
"Carlo (MCP only)" <carlodevREM***@gmail.com> schrieb
> Hi all
> I need to write some strings on a Graphic surface of a simple
> control with a color that is not blend with background color.
> To get this, I simply need set CompositingMode to SourceCopy.
> This is the code:
>
>   Dim aGraphicSurface As Graphics = CType(mObject,
> Control).Parent.CreateGraphics
>   aGraphicSurface.CompositingMode = CompositingMode.SourceCopy
>   aGraphicSurface.DrawString(mCaptionText, mCaptionFont, _
>                              New SolidBrush(mCaptionColor), _
>                              mTextRectangle, _
>                              mStringFormat)
>
> The above code reises me an ArgumentException (invalid parameter)
> error.
>
> I cannot understand why the error is raised.
> Some additional notes:
> DrawImage works correctly.
> Removing aGraphicSurface.CompositingMode =
> CompositingMode.SourceCopy everything works correctly.
> I also tried to set different Alpha levels of mCaptionColor.
> I also tried  to change other Graphics setings (such as
> CompositionQuality, InterpolationMode, SmoothingMode,
> TextRenderingHint, ecc.), without results.
>
> Could you please help me?


I got the same exception. After setting

aGraphicSurface.TextRenderingHint =
System.Drawing.Text.TextRenderingHint.SingleBitPerPixel

there was no exception anymore.


Armin
Author
9 Mar 2006 7:46 AM
Carlo (MCP only)
Show quote Hide quote
"Armin Zingler" <az.nospam@freenet.de> ha scritto nel messaggio
news:ObC5LEqQGHA.1556@TK2MSFTNGP09.phx.gbl...
> "Carlo (MCP only)" <carlodevREM***@gmail.com> schrieb
>> Hi all
>> I need to write some strings on a Graphic surface of a simple
>> control with a color that is not blend with background color.
>> To get this, I simply need set CompositingMode to SourceCopy.
>> This is the code:
>>
>>   Dim aGraphicSurface As Graphics = CType(mObject,
>> Control).Parent.CreateGraphics
>>   aGraphicSurface.CompositingMode = CompositingMode.SourceCopy
>>   aGraphicSurface.DrawString(mCaptionText, mCaptionFont, _
>>                              New SolidBrush(mCaptionColor), _
>>                              mTextRectangle, _
>>                              mStringFormat)
>>
>> The above code reises me an ArgumentException (invalid parameter)
>> error.
>>
>> I cannot understand why the error is raised.
>> Some additional notes:
>> DrawImage works correctly.
>> Removing aGraphicSurface.CompositingMode =
>> CompositingMode.SourceCopy everything works correctly.
>> I also tried to set different Alpha levels of mCaptionColor.
>> I also tried  to change other Graphics setings (such as
>> CompositionQuality, InterpolationMode, SmoothingMode,
>> TextRenderingHint, ecc.), without results.
>>
>> Could you please help me?
>
>
> I got the same exception. After setting
>
> aGraphicSurface.TextRenderingHint =
> System.Drawing.Text.TextRenderingHint.SingleBitPerPixel
>
> there was no exception anymore.
>
>
> Armin


Hello Armin

thank you very much for the suggestion. I noted, however, that setting
TextRenderingHint = TextRenderingHint.SingleBitPerPixel causes a dramatic
text quality loss. Did you solved this problem in some way?

Thnk you

Carlo
Author
9 Mar 2006 9:28 AM
Armin Zingler
Show quote Hide quote
"Carlo (MCP only)" <carlodevREM***@gmail.com> schrieb
> > I got the same exception. After setting
> >
> > aGraphicSurface.TextRenderingHint =
> > System.Drawing.Text.TextRenderingHint.SingleBitPerPixel
> >
> > there was no exception anymore.
> >
> >
> > Armin
>
>
> Hello Armin
>
> thank you very much for the suggestion. I noted, however, that
> setting TextRenderingHint = TextRenderingHint.SingleBitPerPixel
> causes a dramatic text quality loss. Did you solved this problem in
> some way?


Yes, by adding "GridFit"


Armin