ASP 이미지 컨트롤 특정 폴더에 저장하려고합니다.ASP 이미지 컨트롤을 폴더로 내보내기
Image1.ImageUrl = "~/fa/barcode.aspx?d=" + Label1.Text.ToUpper();
이 barcode.aspx이 무엇을 기본적으로 :
Bitmap oBitmap = new Bitmap(w, 100);
// then create a Graphic object for the bitmap we just created.
Graphics oGraphics = Graphics.FromImage(oBitmap);
oGraphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.None;
oGraphics.TextRenderingHint = TextRenderingHint.SingleBitPerPixel;
// Let's create the Point and Brushes for the barcode
PointF oPoint = new PointF(2f, 2f);
SolidBrush oBrushWrite = new SolidBrush(Color.Black);
SolidBrush oBrush = new SolidBrush(Color.White);
// Now lets create the actual barcode image
// with a rectangle filled with white color
oGraphics.FillRectangle(oBrush, 0, 0, w, 100);
// We have to put prefix and sufix of an asterisk (*),
// in order to be a valid barcode
oGraphics.DrawString("*" + Code + "*", oFont, oBrushWrite, oPoint);
Response.ContentType = "image/jpeg";
oBitmap.Save(Response.OutputStream, ImageFormat.Jpeg);
가 어떻게 폴더 (~/FA가/barcodeimages/)에 저장합니까? 지금까지 여기에 내가 시도 내용은 다음과 같습니다
WebClient webClient = new WebClient();
string remote = "http://" + Request.Url.Authority.ToString() + "/fa/barcode.aspx?d=" + Label1.Text.ToUpper();
string local = Server.MapPath("barcodeimages/" + Label1.Text.ToUpper() + ".jpeg");
webClient.DownloadFile(remote, local);
을하지만이 작동하지 않습니다, 난 항상 손상의 .jpeg 파일을 얻을. 그리고 비효율적 인 것처럼 보입니다.
'oBitmap'의 출처에 대해 설명하지 않았거나 이미지 컨트롤을 "저장"하는 것이 실제로 무엇을 의미하는지 설명하지 않았습니다. 이미지 데이터 그 자체는 어디에 있고, 정확히 무엇을 저장하려고합니까? –
@JonSkeet 사실 바코드 이미지입니다. 게시물을 편집하여 코드를 포함 시켰습니다. 내가하고 싶은 것은 이미지를 내 웹 사이트의 폴더로 복사/내보내기하는 것입니다. 따라서 결과는 웹 사이트 폴더에 파일이 있습니다 (~/fa/barcodeimages/barcode1.jpeg). –
@PodMays : 브라우저에서 URL을 입력하면 jpeg가 올바르게 렌더링됩니까? 그렇지 않다면 문제는 비트 맵이 생성되는 방식입니다. – shahkalpesh