2011-03-04 3 views
1

다음 코드는 Windows 양식에서 작동합니다. Silverlight에서 어떻게이 작업을 수행 할 수 있습니까? 그래픽 개체가없는 것 같습니다.Windows 양식의 그래픽을 Silverlight로 변환 하시겠습니까?

 

Bitmap bm = new Bitmap(600, 600); 
Graphics g = Graphics.FromImage(bm); 
Brush b = new LinearGradientBrush(
new Point(1, 1), new Point(600, 600), 
Color.White, Color.Red); 
Point[] points = new Point[] 
{new Point(10, 10), 
new Point(77, 500), 
new Point(590, 100), 
new Point(250, 590), 
new Point(300, 410)}; 
g.FillPolygon(b, points); 
bm.Save("testandoImagem.jpg", ImageFormat.Jpeg); 

 

답변

2

앨런, 심지어 SL 클라이언트 응용 프로그램에서이 모든 서버 측 작업을 수행 할 수 있습니다, 당신은 사용자 인터페이스에 아무것도 표시되지 않는, 내가 .NET에 대한 전체 액세스 권한이있는 비즈니스 계층에서이 코드를 넣어 것입니다 뼈대. SL에서는 클라이언트 시스템에 직접 저장할 수 없으므로 다른 방법을 사용해야합니다.

1

셰이프를 WriteableBitmap으로 렌더링 할 수 있지만 Silverlight에는 데이터를 JPEG로 인코딩하기위한 지원 기능이 기본적으로 제공되지 않습니다.

How to save BitmapImage/WriteableBitmap using SaveFileDialog in Silverlight 3.0?

Best Jpeg Encoder for Silverlight 4.0

http://msdn.microsoft.com/en-us/library/system.windows.media.imaging.writeablebitmap.render(v=VS.95).aspx

 WriteableBitmap wb = new WriteableBitmap(600, 600); 
     Polygon p = new Polygon(); 
     p.Points = new PointCollection() { new Point(10, 10), new Point(77, 500), new Point(590, 100), new Point(250, 590), new Point(300, 410) }; 
     p.Fill = new LinearGradientBrush() 
     { 
      //Gradient angle is 0,0 to 1,1 by default 
      GradientStops = new GradientStopCollection() { 
       new GradientStop() { Color = Colors.White, Offset = 0 }, 
       new GradientStop() { Color = Colors.Red, Offset = 1 } } 
     }; 

     wb.Render(p, null); 
     wb.Invalidate(); 

     //Save WriteableBitmap as described in other questions 
:

이 StackOverflow의 질문을 참조하십시오

관련 문제