Imports System.IO
Imports System.Windows.Forms
Imports System.Drawing
Imports System.Drawing.Imaging
Imports System.Drawing.Drawing2D
Public Class Form1
Private sourceImage As Bitmap
Private isDrawing As Boolean
Private lastPoint As Point
Private sourceImage1 As Bitmap
Private sourceImage2 As Bitmap
Private isDrawingText As Boolean
Private lastTextPoint As Point
'加一个集合来存储每次输入文字的位置和文本
Private textPositionsAndTexts As New List(Of Tuple(Of Point, String))
Private isSelecting As Boolean
Private selectionStartPoint As Point
Private selectionEndPoint As Point
Private isMovingText As Boolean '标识是否正在移动文字
Private movingTextIndex As Integer '正在移动的文字在集合中的索引
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
InitializeTrackBar()
End Sub
Private Sub InitializeTrackBar()
'置滑动条的属性
TrackBar1.Minimum = -255
TrackBar1.Maximum = 255
TrackBar1.Value = 0
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles Button1.Click
Dim openFileDialog1 As New OpenFileDialog()
openFileDialog1.Filter = "图片文件|*.jpg;*.jpeg;*.png;*.gif;*.bmp"
openFileDialog1.Title = "选择图片"
If openFileDialog1.ShowDialog() = DialogResult.OK Then
sourceImage = New Bitmap(openFileDialog1.FileName)
PictureBox1.Image = sourceImage
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles Button2.Click
Dim saveFileDialog1 As New SaveFileDialog()
saveFileDialog1.Filter = "JPEG 图像|*.jpg"
saveFileDialog1.Title = "保存图片"
If saveFileDialog1.ShowDialog() = DialogResult.OK Then
Try
Dim bitmap As New Bitmap(sourceImage)
bitmap.Save(saveFileDialog1.FileName, ImageFormat.Jpeg)
Catch ex As Exception
MessageBox.Show("保存图片时出错: " & ex.Message)
End Try
End If
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles Button3.Click
Dim saveFileDialog1 As New SaveFileDialog()
saveFileDialog1.Filter = "JPEG 图像|*.jpg|PNG 图像|*.png|BMP 图像|*.bmp"
saveFileDialog1.Title = "保存图片"
If saveFileDialog1.ShowDialog() = DialogResult.OK Then
Try
Dim bitmap As New Bitmap(sourceImage)
Select Case saveFileDialog1.FilterIndex
Case 1 'JPEG
bitmap.Save(saveFileDialog1.FileName, ImageFormat.Jpeg)
Case 2 'PNG
bitmap.Save(saveFileDialog1.FileName, ImageFormat.Png)
Case 3 'BMP
bitmap.Save(saveFileDialog1.FileName, ImageFormat.Bmp)
End Select
Catch ex As Exception
MessageBox.Show("保存图片时出错: " & ex.Message)
End Try
End If
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles Button4.Click
If sourceImage IsNot Nothing Then
Dim startX As Integer = 10 '裁剪起始的 X 坐标
Dim startY As Integer = 10 '裁剪起始的 Y 坐标
Dim cropWidth As Integer = 100 '裁剪的宽度
Dim cropHeight As Integer = 100 '裁剪的高度
Dim croppedImage As Bitmap = New Bitmap(cropWidth, cropHeight)
Using graphics As Graphics = Graphics.FromImage(croppedImage)
graphics.DrawImage(sourceImage, New Rectangle(0, 0, cropWidth, cropHeight), startX, startY, cropWidth, cropHeight, GraphicsUnit.Pixel)
End Using
Dim saveFileDialog1 As New SaveFileDialog()
saveFileDialog1.Filter = "JPEG 图像|*.jpg|PNG 图像|*.png|BMP 图像|*.bmp"
saveFileDialog1.Title = "保存裁剪后的图片"
If saveFileDialog1.ShowDialog() = DialogResult.OK Then
Try
Select Case saveFileDialog1.FilterIndex
Case 1 'JPEG
croppedImage.Save(saveFileDialog1.FileName, ImageFormat.Jpeg)
Case 2 'PNG
croppedImage.Save(saveFileDialog1.FileName, ImageFormat.Png)
Case 3 'BMP
croppedImage.Save(saveFileDialog1.FileName, ImageFormat.Bmp)
End Select
Catch ex As Exception
MessageBox.Show("保存图片时出错: " & ex.Message)
End Try
End If
Else
MessageBox.Show("请先打开图片再进行裁剪操作")
End If
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles Button5.Click
If sourceImage IsNot Nothing Then
Dim flippedHorizontallyImage As Bitmap = FlipImageHorizontally(sourceImage)
PictureBox1.Image = flippedHorizontallyImage
Else
MessageBox.Show("请先打开图片再进行水平翻转操作")
End If
End Sub
Private Function FlipImageHorizontally(ByVal image As Bitmap) As Bitmap
Dim flippedImage As New Bitmap(image.Width, image.Height)
For y As Integer = 0 To image.Height - 1
For x As Integer = 0 To image.Width - 1
flippedImage.SetPixel(image.Width - 1 - x, y, image.GetPixel(x, y))
Next
Next
Return flippedImage
End Function
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles Button6.Click
If sourceImage IsNot Nothing Then
Dim flippedVerticallyImage As Bitmap = FlipImageVertically(sourceImage)
PictureBox1.Image = flippedVerticallyImage
Else
MessageBox.Show("请先打开图片再进行垂直翻转操作")
End If
End Sub
Private Function FlipImageVertically(ByVal image As Bitmap) As Bitmap
Dim flippedImage As New Bitmap(image.Width, image.Height)
For y As Integer = 0 To image.Height - 1
For x As Integer = 0 To image.Width - 1
flippedImage.SetPixel(x, image.Height - 1 - y, image.GetPixel(x, y))
Next
Next
Return flippedImage
End Function
Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles Button7.Click
If sourceImage IsNot Nothing Then
Using graphics As Graphics = Graphics.FromImage(sourceImage)
Dim font As New Font("Arial", 20, FontStyle.Bold)
Dim brush As New SolidBrush(Color.Red)
graphics.SmoothingMode = SmoothingMode.AntiAlias
graphics.InterpolationMode = InterpolationMode.HighQualityBicubic
graphics.DrawString("这是按钮输入的文字", font, brush, 50, 50)
End Using
PictureBox1.Image = sourceImage
Else
MessageBox.Show("请先打开图片再添加文字")
End If
End Sub
Private Sub PictureBox1_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs)Handles PictureBox1.MouseDown
If e.Button = MouseButtons.Left Then
isSelecting = True
selectionStartPoint = e.Location
End If
If e.Button = MouseButtons.Right Then
If isDrawingText Then
'开始输入文字时,记录初始位�
没有合适的资源?快使用搜索试试~ 我知道了~
VS2010旗舰版VB.NET版本图片编辑源代码QZQ.zip
![preview](https://csdnimg.cn/release/downloadcmsfe/public/img/white-bg.ca8570fa.png)
共40个文件
vb:6个
txt:5个
jpg:5个
![preview-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/scale.ab9e0183.png)
需积分: 5 0 下载量 52 浏览量
2024-08-11
08:59:07
上传
评论
收藏 1.24MB ZIP 举报
温馨提示
VS2010旗舰版VB.NET版本图片编辑源代码QZQ.zip
资源推荐
资源详情
资源评论
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
收起资源包目录
![package](https://csdnimg.cn/release/downloadcmsfe/public/img/package.f3fc750b.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/TXT.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/TXT.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/EXE.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/EXE.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/EXE.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JPG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JPG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/TXT.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/TXT.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JPG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/BMP.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JPG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JPG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/TXT.png)
共 40 条
- 1
资源评论
![avatar-default](https://csdnimg.cn/release/downloadcmsfe/public/img/lazyLogo2.1882d7f4.png)
![avatar](https://profile-avatar.csdnimg.cn/7e81a1787a66420da3a2e7e956339a5e_qq_32257509.jpg!1)
![avatar-vip](https://csdnimg.cn/release/downloadcmsfe/public/img/user-vip.1c89f3c5.png)
EYYLTV
- 粉丝: 2875
- 资源: 1273
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
最新资源
- gtk3-runtime-3.24.8-64bit
- imTwo 即时通讯 融云
- Linux环境一键执行脚本命令安装msyql,主打的就是便捷
- imOne 即使通讯 融云
- 基于 Bootstrap+Echarts +Java SpringBoot 实现数字化水资源监测全景驾驶舱项目
- 带http-image-filter-module的nginx(windows版)
- cherry pick操作git 将一个分支的多次提交merge到另一个分支(基于TortoiseGit客户端图文)
- Python 毕业设计基于 opencv、Dlib 的人脸识别门禁系统代码+使用教程
- 贷款平台源码/卡卡贷源码/小贷源码/完美版
- Scratch语言入门教程,简易、有趣、实用.pdf
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback-tip](https://img-home.csdnimg.cn/images/20220527035111.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)