Connecting Tech Pros Worldwide Help | Site Map

GDI color depth?

  #1  
Old November 6th, 2008, 12:35 AM
RobT
Guest
 
Posts: n/a
I'll admit, that I don't do a lot of GDI+ programming and I'm sure this is
an easy answer. I'm trying to draw a couple of shapes in a web site. I can
display them just fine, but on some of the fill colors are pixelated. Is
there a way to render these colors at a better color depth?

Dim bmp As Bitmap
bmp = New Bitmap(200, 200)
Dim g As Graphics
g = Graphics.FromImage(bmp)
g.Clear(Color.White)
g.SmoothingMode = SmoothingMode.AntiAlias
Dim brsh As SolidBrush
brsh = New SolidBrush(Color.DarkGoldenrod)
g.FillPie(brsh, 10, 10, 50, 50, 0, 360)

Thanks

  #2  
Old November 6th, 2008, 12:45 AM
Herfried K. Wagner [MVP]
Guest
 
Posts: n/a

re: GDI color depth?


"RobT" <rtorcellini@NOwalchemSPAM.comschrieb:
Quote:
I'll admit, that I don't do a lot of GDI+ programming and I'm sure this is
an easy answer. I'm trying to draw a couple of shapes in a web site. I
can display them just fine, but on some of the fill colors are pixelated.
Is there a way to render these colors at a better color depth?
>
Dim bmp As Bitmap
bmp = New Bitmap(200, 200)
Dim g As Graphics
g = Graphics.FromImage(bmp)
g.Clear(Color.White)
g.SmoothingMode = SmoothingMode.AntiAlias
Dim brsh As SolidBrush
brsh = New SolidBrush(Color.DarkGoldenrod)
g.FillPie(brsh, 10, 10, 50, 50, 0, 360)
Take a look at the different constructors of the 'Bitmap' class. In
addition, take a look at the different overloads of the 'Save' method. Note
that some image formats, such as GIF, only support a certain number of
colors in the image making dithering necessary.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

  #3  
Old November 6th, 2008, 01:05 AM
RobT
Guest
 
Posts: n/a

re: GDI color depth?


Thanks for the pointers. I did modify the Save method to be jpeg instead
and that helps.

bmp.Save(Response.OutputStream, ImageFormat.Jpeg)

Now, is there a way to reduce the amount of compression of the jpeg so the
image is sharper? I(I have some other lines, text etc in my output). The
antialias looks fine...I'm pretty sure the compression is too high.

Thanks!

"Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.atwrote in message
news:eIK7Ng6PJHA.3936@TK2MSFTNGP06.phx.gbl...
Quote:
"RobT" <rtorcellini@NOwalchemSPAM.comschrieb:
Quote:
>I'll admit, that I don't do a lot of GDI+ programming and I'm sure this
>is an easy answer. I'm trying to draw a couple of shapes in a web site.
>I can display them just fine, but on some of the fill colors are
>pixelated. Is there a way to render these colors at a better color depth?
>>
> Dim bmp As Bitmap
> bmp = New Bitmap(200, 200)
> Dim g As Graphics
> g = Graphics.FromImage(bmp)
> g.Clear(Color.White)
> g.SmoothingMode = SmoothingMode.AntiAlias
> Dim brsh As SolidBrush
> brsh = New SolidBrush(Color.DarkGoldenrod)
> g.FillPie(brsh, 10, 10, 50, 50, 0, 360)
>
Take a look at the different constructors of the 'Bitmap' class. In
addition, take a look at the different overloads of the 'Save' method.
Note that some image formats, such as GIF, only support a certain number
of colors in the image making dithering necessary.
>
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
  #4  
Old November 6th, 2008, 01:45 AM
Armin Zingler
Guest
 
Posts: n/a

re: GDI color depth?


"RobT" <rtorcellini@NOwalchemSPAM.comschrieb
Quote:
Now, is there a way to reduce the amount of compression of the jpeg so the
image is sharper? I(I have some other lines, text etc in my output).
The antialias looks fine...I'm pretty sure the compression is too high.
http://msdn.microsoft.com/en-us/library/bb882583.aspx


Armin

  #5  
Old November 6th, 2008, 02:15 AM
RobT
Guest
 
Posts: n/a

re: GDI color depth?


Thanks....I just discovered that myself! Works great.

"Armin Zingler" <az.nospam@freenet.dewrote in message
news:u8sDt$6PJHA.1148@TK2MSFTNGP05.phx.gbl...
Quote:
"RobT" <rtorcellini@NOwalchemSPAM.comschrieb
Quote:
>Now, is there a way to reduce the amount of compression of the jpeg so
>the
>image is sharper? I(I have some other lines, text etc in my output).
>The antialias looks fine...I'm pretty sure the compression is too high.
>
http://msdn.microsoft.com/en-us/library/bb882583.aspx
>
>
Armin
>
  #6  
Old November 6th, 2008, 09:15 AM
Andrew Morton
Guest
 
Posts: n/a

re: GDI color depth?


RobT wrote:
Quote:
Thanks for the pointers. I did modify the Save method to be jpeg
instead and that helps.
>
bmp.Save(Response.OutputStream, ImageFormat.Jpeg)
>
Now, is there a way to reduce the amount of compression of the jpeg
so the image is sharper? I(I have some other lines, text etc in my
output). The antialias looks fine...I'm pretty sure the compression
is too high.
Depending on your target audience, png could be a suitable file format.

Andrew


Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
GDI Color Depth RobT answers 1 November 6th, 2008 02:35 AM
Convert bitmap color depth botched answers 3 August 1st, 2008 04:25 PM
Can't create an 4bpp Bitmap (A generic error occurred in GDI+.) news.microsoft.com answers 0 October 12th, 2006 05:45 PM
Another "A generic error occured in GDI+" Error lgbjr answers 13 November 21st, 2005 01:36 PM