2011-10-21 5 views

답변

0

SaveImage 메서드를 사용하여 ChartWebControl을 으로 저장 한 다음 Stream 개념을 사용하여이 이미지를 이진 데이터로 변환하고이 이진 데이터를 데이터베이스에 저장할 수 있습니다. File Stream 클래스를 사용하여 차트 이미지를 2 진수로 변환 할 수 있습니다.

this.ChartWebControl1.SaveImage(Server.MapPath("Chart.png")); 
byte[] buffer = ImageToBinary(Server.MapPath("Chart.png")); 
//Insert the above buffer data to db for chart image binary data 
-------------------------------- 
public static byte[] ImageToBinary(string imagePath) 
{ 
    FileStream fileStream = new FileStream(imagePath, FileMode.Open, FileAccess.Read); 
    byte[] buffer = new byte[fileStream.Length]; 
    fileStream.Read(buffer, 0, (int)fileStream.Length); 
    fileStream.Close(); 
    return buffer; 
} 

당신은 이미지에 다시 바이너리 데이터를 변환 할 수있는 코드 아래

[C 번호]를 참조하시기 바랍니다, 코드 아래를 참조하십시오.

[C 번호]

public static Image BinaryToImage(System.Data.Linq.Binary binaryData) 
{ 
    if (binaryData == null) return null; 
    byte[] buffer = binaryData.ToArray(); 
    MemoryStream memStream = new MemoryStream(); 
    memStream.Write(buffer, 0, buffer.Length); 
    return Image.FromStream(memStream); 
} 
관련 문제