2013-07-09 5 views
1

워터 마크를 추가하여 동일한 워터 마크를 제거하는 프로그램을 만든 후에 오늘 과제를 수행했습니다.vb.net 이미지 조작

내 생각에 이미지가 이제 이미지의 일부이므로 쉽게 제거 할 수 없습니다.

정확합니까, 아니면 실제로입니까? 내 코드는 워터 마크를 추가하는 모든 힌트

다음

에 대한

감사 (나던 10 년이 걸릴) :

Dim watermark_bm As Bitmap = Global.AnchorAuditor.My.Resources.Logo_White 
    Dim watermark_bm2 As Bitmap = Global.AnchorAuditor.My.Resources.CLS_Logo_White_Engineering 

    'watermark_bm2.MakeTransparent() 

    ' WATERMARK IMAGE 1 - AA 
    Using str As Stream = File.OpenRead(s) 

     Dim or_bm As Bitmap = Image.FromStream(str) 

     '''''''''''''''''''''''''START IMAGE 1'''''''''''''''''''''''''' 

     or_bm.SetResolution(20, 20) 

     Dim x1 As Integer = or_bm.Width - 300 
     Dim Y As Integer = or_bm.Height - 300 

     Const ALPHA As Byte = 128 
     ' Set the watermark's pixels' Alpha components. 
     Dim clr As Color 
     For py As Integer = 0 To watermark_bm.Height - 1 
      For px As Integer = 0 To watermark_bm.Width - 1 
       clr = watermark_bm.GetPixel(px, py) 
       watermark_bm.SetPixel(px, py, _ 
        Color.FromArgb(ALPHA, clr.R, clr.G, clr.B)) 
      Next px 
     Next py 

     ' Set the watermark's transparent color. 
     watermark_bm.MakeTransparent(watermark_bm.GetPixel(0, _ 
      0)) 

     ' Copy onto the result image. 
     Dim gr As Graphics = Graphics.FromImage(or_bm) 
     gr.DrawImage(watermark_bm, x1, Y) 

     '''''''''''''''''''''''''END IMAGE 1 START IMAGE 2'''''''''''''''''''''''''' 

     or_bm.SetResolution(60, 60) 

     Dim x2 As Integer = 75 
     Dim Y1 As Integer = 75 

     Const ALPHA1 As Byte = 128 
     ' Set the watermark's pixels' Alpha components. 
     Dim clr1 As Color 
     For py As Integer = 0 To watermark_bm2.Height - 1 
      For px As Integer = 0 To watermark_bm2.Width - 1 
       clr1 = watermark_bm2.GetPixel(px, py) 
       watermark_bm2.SetPixel(px, py, _ 
        Color.FromArgb(ALPHA1, clr1.R, clr1.G, clr1.B)) 
      Next px 
     Next py 

     ' Set the watermark's transparent color. 
     watermark_bm2.MakeTransparent(watermark_bm2.GetPixel(0, _ 
      0)) 

     ' Copy onto the result image. 
     Dim gr1 As Graphics = Graphics.FromImage(or_bm) 
     gr1.DrawImage(watermark_bm2, x2, Y1) 


     ''''''''''''''''''''''''END IMAGE 2''''''''''''''''''''''''''' 
     or_bm.Save(s & "deleteme.jpg", _ 
     System.Drawing.Imaging.ImageFormat.Jpeg) 

    End Using 

답변

3

을 당신이 맞아요 - 워터 마크를 추가하는 것이 훨씬 더 쉽다 그것을 제거하는 것보다. 표준 접근법은 원래의 복사본을 유지하고 나중에 이미지를 조작하는 대신에 그것을 사용하는 것입니다.

+0

감사합니다. 그렇게 생각 했나요? – Pakk