我正在尝试从网站添加图片,我正面临一个问题,那就是当我试图去谷歌图片并尝试添加一些图片时,当我右键点击某些图片时,我发现“复制图像URL“和某些我找不到它,我找到”复制链接地址“。现在我希望我的用户限制添加包含”复制图像URL“的图像 我正在附上图片,以便您以更好的方式理解我。
我该怎么做?
以下是保存图片的代码:
Dim dir_name As String = txtDirectory.Text
If Not dir_name.EndsWith("\") Then dir_name &= "\"
For Each pic As PictureBox In flpPictures.Controls
Dim bm As Bitmap = CType(pic.Image, Bitmap)
Dim filename As String = CStr(pic.Tag)
filename = filename.Substring(filename.LastIndexOf("/") + 1)
Dim ext As String = filename.Substring(filename.LastIndexOf("."))
'Here it gives me an error at(filename.lastindexof(".")
Dim full_name As String = dir_name & filename
Select Case ext
Case ".bmp"
bm.Save(full_name, Imaging.ImageFormat.Bmp)
Case ".gif"
bm.Save(full_name, Imaging.ImageFormat.Gif)
Case ".jpg", "jpeg"
bm.Save(full_name, Imaging.ImageFormat.Jpeg)
Case ".png"
bm.Save(full_name, Imaging.ImageFormat.Png)
Case ".tiff"
bm.Save(full_name, Imaging.ImageFormat.Tiff)
Case Else
MessageBox.Show( _
"Unknown file type " & ext & _
" in file " & filename, _
"Unknown File Type", _
MessageBoxButtons.OK, _
MessageBoxIcon.Error)
End Select
Next pic
Beep()
答案 0 :(得分:0)
在顶部屏幕截图中,您右键单击图像。
在底部屏幕截图中,您右键单击带有z-index的空div,将其置于图像上方。
以下是一个例子:
<a href="http://example.com">
<img src="myImg.jpg" style="position: absolute;" />
<div style="z-index:1; position:absolute; width:100%; height:100%;"></div>
</a>
当您将鼠标悬停在Google图片中的链接上时,顶部会显示另一个包含可保存图像的div。看看Firebug并亲自看看:)
请注意,没有完美的方法可以阻止用户保存您网站上的图片。您可以禁用右键单击,使用div屏蔽图像,使用透明图像屏蔽图像(这样用户可以右键单击并保存图像,但是它们会出错),防止缓存等,但最终任何精通技术的用户都可以绕过这个。尽管如此,这些方法将阻止临时用户,所以它总比没有好。如果你想了解更多关于我刚刚命名的方法的信息,我建议谷歌搜索“禁用保存图像为”或“禁用复制图像网址”。
答案 1 :(得分:0)
也许有帮助
Sub Base64Convert(ByVal Base64MSG As String) 'Setup image and get data stream together Dim img As System.Drawing.Image Dim MS As System.IO.MemoryStream = New System.IO.MemoryStream Dim b64 As String = Base64MSG Dim b() As Byte 'Converts the base64 encoded msg to image data b = Convert.FromBase64String(b64) MS = New System.IO.MemoryStream(b) 'creates image img = System.Drawing.Image.FromStream(MS) 'writes image for displaying img.Save(Request.ServerVariables("APPL_PHYSICAL_PATH") & "LabelInfo.tiff", System.Drawing.Imaging.ImageFormat.Tiff) 'cleaning up house img.Dispose() MS.Close() End Sub
答案 2 :(得分:0)
'WEB CLIENT IS NEEDED TO DO THE DOWNLOAD Dim MyWebClient As New System.Net.WebClient 'BYTE ARRAY HOLDS THE DATA Dim ImageInBytes() As Byte = MyWebClient.DownloadData(url) 'CREATE A MEMORY STREAM USING THE BYTES Dim ImageStream As New IO.MemoryStream(ImageInBytes) 'CREATE A BITMAP FROM THE MEMORY STREAM PictureBox1.Image = New System.Drawing.Bitmap(ImageStream)