Handler.ashx -> return picture
Moderators: SDS, support, admin
Handler.ashx -> return picture
Hello,
I am going to buy CadSoftTools but I have to test it before.
Please help me finish my job.
I have to create ashx file for web service. It should produce image for a given dxf file.
What I need is a good idea how to receive and return picture designed by Cad library.
On output I need image context.Response.WriteFile( takeCad() ); but now is problem.
I attached my ashx file.
Thank you dear friends!
Piotr
<%@ WebHandler Language="C#" Class="Handler" %>
using System.Drawing.Imaging;
using System;
using System.Web;
using CADImport;
using CADImport.RasterImage;
using CADImport.DWG;
public class Handler : IHttpHandler {
public void ProcessRequest (HttpContext context) {
// context.Response.ContentType = "text/plain";
// context.Response.Write("Hello World");
string loc = "~/APQP_na.bmp";
context.Response.ContentType = "image/gif";
//context.Response.WriteFile( takeCad() );
}
private string outFileName = @"testasp3.gif";
private CADImage cadImage;
DRect boundaryRectangle;
int left=0;
int top=0;
int width=550;
int height=550;
string inFileName="test.dxf";
public CADImage takeCad()
{
boundaryRectangle = new DRect(left, top, width, height);
cadImage = CADImage.CreateImageByExtension(inFileName);
cadImage.UseDoubleBuffering = false;
cadImage.LoadFromFile(inFileName);
ImageFormat imgFrm = ImageFormat.Gif;
cadImage.ChangeDrawMode(DrawGraphicsMode.GDIPlus, null);
cadImage.BorderSize = 0;
cadImage.DrawMode = CADDrawMode.Black;
System.Drawing.Rectangle rect = new System.Drawing.Rectangle((int)left, (int)top, (int)width, (int)height);
return (cadImage);
}
public bool IsReusable {
get {
return false;
}
}
}
Thank you
http://www.EuroDolar.pl
I am going to buy CadSoftTools but I have to test it before.
Please help me finish my job.
I have to create ashx file for web service. It should produce image for a given dxf file.
What I need is a good idea how to receive and return picture designed by Cad library.
On output I need image context.Response.WriteFile( takeCad() ); but now is problem.
I attached my ashx file.
Thank you dear friends!
Piotr
<%@ WebHandler Language="C#" Class="Handler" %>
using System.Drawing.Imaging;
using System;
using System.Web;
using CADImport;
using CADImport.RasterImage;
using CADImport.DWG;
public class Handler : IHttpHandler {
public void ProcessRequest (HttpContext context) {
// context.Response.ContentType = "text/plain";
// context.Response.Write("Hello World");
string loc = "~/APQP_na.bmp";
context.Response.ContentType = "image/gif";
//context.Response.WriteFile( takeCad() );
}
private string outFileName = @"testasp3.gif";
private CADImage cadImage;
DRect boundaryRectangle;
int left=0;
int top=0;
int width=550;
int height=550;
string inFileName="test.dxf";
public CADImage takeCad()
{
boundaryRectangle = new DRect(left, top, width, height);
cadImage = CADImage.CreateImageByExtension(inFileName);
cadImage.UseDoubleBuffering = false;
cadImage.LoadFromFile(inFileName);
ImageFormat imgFrm = ImageFormat.Gif;
cadImage.ChangeDrawMode(DrawGraphicsMode.GDIPlus, null);
cadImage.BorderSize = 0;
cadImage.DrawMode = CADDrawMode.Black;
System.Drawing.Rectangle rect = new System.Drawing.Rectangle((int)left, (int)top, (int)width, (int)height);
return (cadImage);
}
public bool IsReusable {
get {
return false;
}
}
}
Thank you
http://www.EuroDolar.pl
Re: Handler.ashx -> return picture
Hello.
.NET Framework provides System.Drawing.Bitmap class that represents a raster image object. Use CADImage.SaveToFile or CADImage.SaveToStream then instantiate an object of Bitmap class by created file or stream.
Alexander.
.NET Framework provides System.Drawing.Bitmap class that represents a raster image object. Use CADImage.SaveToFile or CADImage.SaveToStream then instantiate an object of Bitmap class by created file or stream.
Alexander.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support