M
macap.usenet
Hello,
I am creating Gif-Images (8bit: 256 colors) with using the
IHttpHandler and .ashx-Files.
My ProcessRequest-Method looks like this:
public void ProcessRequest(HttpContext context)
{
object o = context.Request["roomId"];
if (o == null)
{
// MP[TODO] ???throw exception???
context.Response.Write("No room found");
context.Response.End();
return;
}
Bitmap bmp = CreateUpcomingDaysImage();
context.Response.ContentType = "image/gif";
bmp.Save(context.Response.OutputStream, ImageFormat.Gif);
bmp.Dispose();
}
But the resulting Gif-Image has Dithering (http://en.wikipedia.org/
wiki/Dithering),
although I only use 2 grey-colors at the moment:
private Bitmap CreateUpcomingDaysImage()
{
Bitmap bmp = new Bitmap(_imageWidth, _imageHeight);
Graphics g = Graphics.FromImage(bmp);
SolidBrush evenCaptionColor = new
SolidBrush(Color.FromArgb(210, 210, 210));
SolidBrush oddCaptionColor = new
SolidBrush(Color.FromArgb(140, 140, 140));
RectangleF rect = new RectangleF();
for (int i = 0; i < _hoursOfDay; i++)
{
rect = new RectangleF(i * _pixel, 0.0F, _pixel,
_pixel);
if (i % 2 == 0)
g.FillRectangle(evenCaptionColor, rect);
else
g.FillRectangle(oddCaptionColor, rect);
}
g.Dispose();
return bmp;
}
Is there a way to avoid Dithering? I am not very sure, but I think
there is a technology
called "indexed colors" in Gif-Files so that the gif file can use 256
different spezified colors.
Can I use this to with the GDI+ Library of .NET? Or what else can I
do?
Regards,
Martin
I am creating Gif-Images (8bit: 256 colors) with using the
IHttpHandler and .ashx-Files.
My ProcessRequest-Method looks like this:
public void ProcessRequest(HttpContext context)
{
object o = context.Request["roomId"];
if (o == null)
{
// MP[TODO] ???throw exception???
context.Response.Write("No room found");
context.Response.End();
return;
}
Bitmap bmp = CreateUpcomingDaysImage();
context.Response.ContentType = "image/gif";
bmp.Save(context.Response.OutputStream, ImageFormat.Gif);
bmp.Dispose();
}
But the resulting Gif-Image has Dithering (http://en.wikipedia.org/
wiki/Dithering),
although I only use 2 grey-colors at the moment:
private Bitmap CreateUpcomingDaysImage()
{
Bitmap bmp = new Bitmap(_imageWidth, _imageHeight);
Graphics g = Graphics.FromImage(bmp);
SolidBrush evenCaptionColor = new
SolidBrush(Color.FromArgb(210, 210, 210));
SolidBrush oddCaptionColor = new
SolidBrush(Color.FromArgb(140, 140, 140));
RectangleF rect = new RectangleF();
for (int i = 0; i < _hoursOfDay; i++)
{
rect = new RectangleF(i * _pixel, 0.0F, _pixel,
_pixel);
if (i % 2 == 0)
g.FillRectangle(evenCaptionColor, rect);
else
g.FillRectangle(oddCaptionColor, rect);
}
g.Dispose();
return bmp;
}
Is there a way to avoid Dithering? I am not very sure, but I think
there is a technology
called "indexed colors" in Gif-Files so that the gif file can use 256
different spezified colors.
Can I use this to with the GDI+ Library of .NET? Or what else can I
do?
Regards,
Martin