Error on Graphics CompositingMode.SourceCopy

  • Thread starter Thread starter Carlo \(MCP only\)
  • Start date Start date
C

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 only) said:
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
 
Armin Zingler said:
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
 
Carlo (MCP only) said:
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
 
Back
Top