2014-05-25 4 views
0

나는 500x500 인 이미지를 가지고 있는데,이 이미지에 500x500 이미지의 오른쪽 위 모서리에있는 32x32 심볼을 복사하려고합니다.어떻게 이미지를 다른 이미지에 쓸 수 있습니까?

나는 그것을에서 렌더링을 시도했지만, 작동하지 않는 것 :

var statusSymbol = new Image() 
{ 
     Source = new BitmapImage(new Uri(tempJPEG, UriKind.Relative)) 
}; 

WriteableBitmap wb = new WriteableBitmap(bitmap); 
wb.Render(statusSymbol , new TranslateTransform() { X = 500-10, Y = 10 }); 
wb.Invalidate(); 
+1

가능한 중복 [어떻게 C#을 사용하여 다른 이미지에 이미지를 포함시키는 방법?] (http://stackoverflow.com/questions/1945907/how-to-embed-an-image-into-another-image-using-c) –

답변

0

수동 방식 (장단점과)의

public Bitmap AddLogo(Bitmap original_image, Bitmap logo) 
    { 
     /// Add validation here (not null, logo smaller then original, etc..) 
     Bitmap with_logo = new Bitmap(original_image);   

     /// To get the right corner use: 
     int x_start_value = (original_image.Width - logo.Width) - 1; 
     int x_stop_value = original_image.Width -1; 
     /// 

     /// You can add ofset (padding) by starting x and\or y from your value insted of 0 

     for (int y = 0; y < logo.Height; y++)    
     { 

      /// For left corner 
      ///for (int x = 0; x < logo.Width; x++) 
      int logo_x = 0; 
      for (int x = x_start_value; x < x_stop_value; x++)     
      { 
       with_logo.SetPixel(x, y, logo.GetPixel(logo_x, y)); 
       logo_x++; 
      } 
     } 

     return with_logo; 
    } 
관련 문제