⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 howto_net_watermark.html

📁 为了让大家能更好的阅读和于是我为大家将网上的资料整理成一个帮助文件。让查阅API 函数变的更简单
💻 HTML
字号:
<HTML>
<META http-equiv="PICS-Label" content='(PICS-1.1 "http://www.rsac.org/ratingsv01.html" l gen true comment "RSACi North America Server" by "RodStephens@vb-helper.com" for "http://www.vb-helper.com" on "1998.03.17T18:18-0800" r (n 0 s 0 v 0 l 0))'>
<HEAD>
<TITLE>VB Helper: HowTo: Add a watermark to an image in VB .NET</TITLE>
<META NAME="Author" CONTENT="Rod Stephens">
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META HTTP-EQUIV="Keywords" CONTENT="watermark, image, image processing">
<META NAME="Keywords" CONTENT="watermark, image, image processing">
<META NAME="Description" CONTENT="VB Helper: HowTo: Add a watermark to an image in VB .NET">
<META NAME="Copyright" CONTENT="Copyright 1997-2003, Rocky Mountain Computer Consulting, Inc.">
<META NAME="Rating" CONTENT="General">
<META NAME="Robots" CONTENT="All">
</HEAD>

<BODY BGCOLOR="#E1F3FF" BACKGROUND="bg_blue.jpg">

  <!-- This table contains the banner, menu column, and content. -->
  <TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0">
    <!-- ****** -->
    <!-- Banner -->
    <!-- ****** -->
    <TR><TD>
      <TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0" ALIGN="Left">
        <TR>
          <TD BACKGROUND="banner_mid.jpg"><IMG SRC="banner_l.jpg" WIDTH="410" HEIGHT="64"></TD>
          <TD BGCOLOR="#E1F3FF"><IMG SRC="banner_r.jpg" WIDTH="32" HEIGHT="64"></TD>
        </TR>
      </TABLE>
    </TD></TR>
    <TR><TD>&nbsp;</TD></TR>

    <!-- Menu column and content -->
    <TR><TD>
      <TABLE WIDTH="100%" BORDER="0" CELLSPACING="2" CELLPADDING="0">
        <!-- *********** -->
        <!-- Menu column -->
        <!-- *********** -->
        <TR>
          <TD ALIGN="Left" VALIGN="Top">
            <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0">
              <!-- Menu top -->
              <TR>
                <TD><IMG SRC="blue_ul.jpg" WIDTH="16" HEIGHT="16"></TD>
                <TD><IMG SRC="blue_um.jpg" WIDTH="93" HEIGHT="16"></TD>
                <TD><IMG SRC="blue_ur.jpg" WIDTH="16" HEIGHT="16"></TD>
              </TR>

              <!-- Menu entries -->
              <TR BGCOLOR="#7FCFFF">
                <TD BACKGROUND="blue_l.jpg" WIDTH="16">&nbsp;</TD>
                <TD><CENTER>
                  <A HREF="index.html"><B><FONT SIZE="+1">Home</FONT></B></A><BR>
                  <A HREF="search.html"><B>Search</B></A><BR>
                  &nbsp;<BR>
                  <A HREF="whats_new.html"><B>What's New</B></A><BR>
                  <A HREF="index_categories.html"><B>Index</B></A><BR>
                  <A HREF="books.html"><B>Books</B></A><BR>
                  <A HREF="links.html"><B>Links</B></A><BR>
                  <A HREF="http://www.topica.com/lists/VBHelperQA/read"><B>Q &amp; A</B></A><BR>
                  <A HREF="newsletter.html"><B>Newsletter</B></A><BR>
                  <A HREF="banners.html"><B>Banners</B></A><BR>
                  &nbsp;<BR>
                  <A HREF="mailto:feedback@vb-helper.com"><B>Feedback</B></A><BR>
                  <A HREF="tip_jar.html"><B>Tip Jar</B></A><BR>
                  &nbsp;<BR>
                  <A HREF="feed.xml"><IMG SRC="xml_rss.jpg" BORDER="0" ALT="XML RSS Feed"></A><BR>
                </CENTER></TD>
                <TD BACKGROUND="blue_r.jpg" WIDTH="16">&nbsp;</TD>
              </TR>

              <!-- Menu bottom -->
              <TR>
                <TD><IMG SRC="blue_ll.jpg" WIDTH="16" HEIGHT="16"></TD>
                <TD><IMG SRC="blue_lm.jpg" WIDTH="93" HEIGHT="16"></TD>
                <TD><IMG SRC="blue_lr.jpg" WIDTH="16" HEIGHT="16"></TD>
              </TR>

              <TR><TD HEIGHT="50" COLSPAN="3">&nbsp;</TR></TD>

              <!-- ******** -->
              <!-- Partners -->
              <!-- ******** -->

              <!-- MVP -->
              <TR><TD COLSPAN="3"><A HREF="http://www.mvps.org"><IMG SRC="mvp_logo.gif" BORDER="0"></A></TR></TD>
              <TR><TD HEIGHT="20" COLSPAN="3">&nbsp;</TR></TD>

              <!-- MSDN VB Community -->
              <TR><TD COLSPAN="3" ALIGN="Center">
<A HREF="http://msdn.microsoft.com/vbasic/community/default.aspx">MSDN Visual Basic Community</A>
              </TD></TR>
              <TR><TD HEIGHT="50" COLSPAN="3">&nbsp;</TR></TD>

              <!-- Amazon Recommends -->
              <TR><TD COLSPAN="3" ALIGN="Center">
<!-- -->
                <SCRIPT SRC="http://rcm.amazon.com/e/cm?t=vbhelper&l=rc1&p=2&o=1" TYPE="text/JavaScript"></SCRIPT>
<!-- -->
                <NOSCRIPT>
                  <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" WIDTH="125">
                    <TR><TD>
                      <MAP NAME="boxmap">
                        <AREA SHAPE="RECT" COORDS="18, 263, 105, 274" HREF="http://rcm.amazon.com/e/cm/privacy-policy.html?o=1">
                        <AREA COORDS="0,0,10000,10000" HREF="http://www.amazon.com/exec/obidos/redirect-home/vbhelper">
                      </MAP>
                      <img src="http://rcm-images.amazon.com/images/G/01/associates/amzn_recommends/gnbox125x275.gif" width="125" height="275" border="0" usemap="#boxmap">
                    </TD></TR>
                  </TABLE>
                </NOSCRIPT>
              </TD></TR>
              <TR><TD HEIGHT="50" COLSPAN="3">&nbsp;</TR></TD>

              <!-- Wiley -->
              <TR><TD COLSPAN="3" ALIGN="Center" BACKGROUND="sandpaper.gif"><A HREF="http://service.bfast.com/bfast/click?bfmid=37920629&siteid=40078832&bfpage=computer_science" TARGET="_top"><IMG SRC="wiley_logo.gif" BORDER="0" ALIGN="Center" WIDTH="77" HEIGHT="105"></TD></TR>
              <TR><TD HEIGHT="10" COLSPAN="3">&nbsp;</TR></TD>

              <!-- Que -->
              <TR><TD COLSPAN="3" ALIGN="Center"><A HREF="http://www.quepublishing.com"><IMG SRC="que.gif" BORDER="0" ALIGN="Center" WIDTH="121" HEIGHT="36"></A></TD></TR>
              <TR><TD HEIGHT="10" COLSPAN="3">&nbsp;</TR></TD>

              <!-- Amazon -->
              <TR><TD COLSPAN="3" ALIGN="Center"><A HREF="amazon.html"><IMG SRC="amazon_logo.gif" BORDER="0" ALIGN="Center" WIDTH="68" HEIGHT="65"></A></TD></TR>
              <TR><TD HEIGHT="10" COLSPAN="3">&nbsp;</TR></TD>

              <!-- ********** -->
              <!-- More stuff -->
              <!-- ********** -->

            </TABLE>
          </TD>

          <!-- A little space between the menus and content -->
          <TD WIDTH="5">&nbsp;</TD>

          <!-- ******* -->
          <!-- Content -->
          <!-- ******* -->
          <TD WIDTH="100%" ALIGN="Left" VALIGN="Top">
            <TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0">
              <!-- How To Summary -->
              <TR><TD>
                <TABLE WIDTH="100%" BORDER="2" CELLSPACING="0" CELLPADDING="2">
                  <TR><TH ALIGN="Left">Title</TH><TD WIDTH="100%">Add a watermark to an image in VB .NET</TD></TR>
                  <TR><TH ALIGN="Left">Description</TH><TD WIDTH="100%">This example shows how to add a watermark to an image in VB .NET. It makes some parts of the watermark image transparent and others translucent.</TD></TR>
                  <TR><TH ALIGN="Left">Keywords</TH><TD>watermark, image, image processing</TD></TR>
                  <TR><TH ALIGN="Left">Categories</TH><TD>Graphics</TD></TR>
                </TABLE>
              </TD></TR>

              <!-- Text content -->
              <TR><TD>&nbsp;<BR></TD></TR>
              <TR><TD>
Subroutine DrawWatermark copies a watermark image onto another image. First it loops through the watermark's pixels setting the alpha component of each to 128 to make them 50 percent opaque.
<P>
It then sets the image's transparent color to the color of the pixel in the upper left corner. This pixel should have the image's background color, as should any other pixels that you want to be transparent in the result.
<P>
The program then copies the watermark image onto the result image.
              </TD></TR>

              <!-- Code content -->
              <TR><TD>&nbsp;<BR></TD></TR>
              <TR>
                <TD BACKGROUND="computer_paper.jpg">
                  <PRE><FONT NAME="Courier New" POINT-SIZE="10" SIZE="2"><FONT COLOR="#008000">' Copy the watermark image over the result image.</FONT>
Private Sub DrawWatermark(ByVal watermark_bm As Bitmap, _
    ByVal result_bm As Bitmap, ByVal x As Integer, ByVal y _
    As Integer)
    Const ALPHA As Byte = 128
    <FONT COLOR="#008000">' Set the watermark's pixels' Alpha components.</FONT>
    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

    <FONT COLOR="#008000">' Set the watermark's transparent color.</FONT>
    watermark_bm.MakeTransparent(watermark_bm.GetPixel(0, _
        0))

    <FONT COLOR="#008000">' Copy onto the result image.</FONT>
    Dim gr As Graphics = Graphics.FromImage(result_bm)
    gr.DrawImage(watermark_bm, x, y)
End Sub</FONT></PRE>
              </TD></TR>

              <!-- Text content -->
              <TR><TD>&nbsp;<BR></TD></TR>
              <TR><TD>
The example program draws two watermarks, one with the surface of letters transparent and one with the surfaces a neutral color.
<P>
You may want to try other alpha values. For example, 64 produces a more subtle result.
<P>
<CENTER><IMG SRC="howto_net_watermark.jpg"></CENTER>
              </TD></TR>

              <!-- *************** -->
              <!-- Download button -->
              <!-- *************** -->

              <TR><TD><FONT SIZE="-2">&nbsp;</FONT></TD></TR>
              <TR><TD ALIGN="Center"><A HREF="HowTo/howto_net_watermark.zip"><IMG SRC="download.jpg" BORDER="0"></A></TD></TR>
              <TR><TD><FONT SIZE="-2">&nbsp;</FONT></TD></TR>

            </TABLE> <!-- End content table -->
          </TD> <!-- End content column -->

          <!-- ************** -->
          <!-- Google AdSense -->
          <!-- ************** -->
          <TD WIDTH="120" ALIGN="Right" VALIGN="Top">
            <TABLE WIDTH="140" BORDER="0" CELLSPACING="0" CELLPADDING="0">
              <TR><TD ALIGN="Right">

<script type="text/javascript"><!--
google_ad_client = "pub-6627515316741006";
google_ad_width = 120;
google_ad_height = 600;
google_ad_format = "120x600_as";
google_ad_channel ="3885326441";
google_color_border = ["5CAAFD","7ECFFE","00CC66","DDAADD"];
google_color_bg = ["7ECFFE","E1F3FF","99FF99","FFCCFF"];
google_color_link = ["0000FF","0000FF","0000FF","0000CC"];
google_color_url = ["008000","008000","0033FF","008000"];
google_color_text = ["000000","000000","000000","996699"];
//--></script>
<script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>

              </TD></TR>
            </TABLE> <!-- End Google AdSense table -->
          </TD> <!-- End Google AdSense column -->


        </TR> <!-- End row containing menu column and content -->
      </TABLE> <!-- End table containing menu column and content -->
    </TD></TR>

    <!-- ****** -->
    <!-- Footer -->
    <!-- ****** -->
    <TR><TD WIDTH="100%">
      <TABLE WIDTH="100%" BORDER="0" BGCOLOR="#87CEFA" CELLSPACING="0" CELLPADDING="0">
        <!-- Top row -->
        <TR>
          <TD BGCOLOR="#E1F3FF" ALIGN="Right" WIDTH="16"><IMG SRC="blue_ul.jpg" WIDTH="16" HEIGHT="16"></TD>
          <TD BACKGROUND="blue_um.jpg" COLSPAN="2" ALIGN="Center"><FONT SIZE="-2">
            Copyright &copy; 1997-2003 Rocky Mountain Computer Consulting, Inc. &nbsp; All rights reserved.
          </FONT></TD>
          <TD BGCOLOR="#E1F3FF"><IMG SRC="blue_ur.jpg" WIDTH="16" HEIGHT="16"></TD>
        </TR>

        <!-- Bottom row -->
        <TR>
          <TD BGCOLOR="#E1F3FF" ALIGN="Right" WIDTH="16"><IMG SRC="blue_ll.jpg" WIDTH="16" HEIGHT="16"></TD>
          <TD BACKGROUND="blue_lm.jpg"><FONT SIZE="-2">
            &nbsp;<SCRIPT LANGUAGE=JavaScript>document.write(document.URL)</SCRIPT></FONT></TD>
          <TD BACKGROUND="blue_lm.jpg" ALIGN="Right"><FONT SIZE="-2">
            Updated <SCRIPT LANGUAGE=JavaScript>document.write(document.lastModified)</SCRIPT> &nbsp;
          </FONT></TD>
          <TD BGCOLOR="#E1F3FF"><IMG SRC="blue_lr.jpg" WIDTH="16" HEIGHT="16"></TD>
        </TR>
      </TABLE>
    </TD></TR>
  </TABLE> <!-- End table containing banner, menu column + content, and footer -->

</BODY>
</HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -