Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
Kivii.Client.Sample.ImageUploader.V4.5
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
陶然
Kivii.Client.Sample.ImageUploader.V4.5
Commits
002a27c7
Commit
002a27c7
authored
May 30, 2024
by
Neo Turing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加裁剪功能
parent
ca552351
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
60 additions
and
64 deletions
+60
-64
FrmImageEditor.Designer.cs
Src/FrmImageEditor.Designer.cs
+29
-12
FrmImageEditor.cs
Src/FrmImageEditor.cs
+9
-36
FrmMain.Designer.cs
Src/FrmMain.Designer.cs
+0
-0
FrmMain.cs
Src/FrmMain.cs
+19
-13
Kivii.Client.Sample.ImageUploader.V4.5.csproj
Src/Kivii.Client.Sample.ImageUploader.V4.5.csproj
+1
-1
AssemblyInfo.cs
Src/Properties/AssemblyInfo.cs
+2
-2
No files found.
Src/FrmImageEditor.Designer.cs
View file @
002a27c7
...
@@ -34,8 +34,10 @@
...
@@ -34,8 +34,10 @@
this
.
plControl
=
new
System
.
Windows
.
Forms
.
Panel
();
this
.
plControl
=
new
System
.
Windows
.
Forms
.
Panel
();
this
.
btnSave
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
btnSave
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
btnCancel
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
btnCancel
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
plImage
=
new
System
.
Windows
.
Forms
.
Panel
();
this
.
imgResizer
=
new
Kivii
.
Sample
.
ImageUploader
.
Controls
.
ImageResizer
();
this
.
imgResizer
=
new
Kivii
.
Sample
.
ImageUploader
.
Controls
.
ImageResizer
();
this
.
plControl
.
SuspendLayout
();
this
.
plControl
.
SuspendLayout
();
this
.
plImage
.
SuspendLayout
();
this
.
SuspendLayout
();
this
.
SuspendLayout
();
//
//
// timeImageEditor
// timeImageEditor
...
@@ -48,9 +50,10 @@
...
@@ -48,9 +50,10 @@
this
.
plControl
.
Controls
.
Add
(
this
.
btnSave
);
this
.
plControl
.
Controls
.
Add
(
this
.
btnSave
);
this
.
plControl
.
Controls
.
Add
(
this
.
btnCancel
);
this
.
plControl
.
Controls
.
Add
(
this
.
btnCancel
);
this
.
plControl
.
Dock
=
System
.
Windows
.
Forms
.
DockStyle
.
Bottom
;
this
.
plControl
.
Dock
=
System
.
Windows
.
Forms
.
DockStyle
.
Bottom
;
this
.
plControl
.
Location
=
new
System
.
Drawing
.
Point
(
0
,
715
);
this
.
plControl
.
Location
=
new
System
.
Drawing
.
Point
(
0
,
391
);
this
.
plControl
.
Margin
=
new
System
.
Windows
.
Forms
.
Padding
(
2
,
2
,
2
,
2
);
this
.
plControl
.
Name
=
"plControl"
;
this
.
plControl
.
Name
=
"plControl"
;
this
.
plControl
.
Size
=
new
System
.
Drawing
.
Size
(
807
,
146
);
this
.
plControl
.
Size
=
new
System
.
Drawing
.
Size
(
584
,
100
);
this
.
plControl
.
TabIndex
=
0
;
this
.
plControl
.
TabIndex
=
0
;
//
//
// btnSave
// btnSave
...
@@ -61,9 +64,8 @@
...
@@ -61,9 +64,8 @@
this
.
btnSave
.
Font
=
new
System
.
Drawing
.
Font
(
"宋体"
,
25F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
btnSave
.
Font
=
new
System
.
Drawing
.
Font
(
"宋体"
,
25F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
btnSave
.
ForeColor
=
System
.
Drawing
.
Color
.
FromArgb
(((
int
)(((
byte
)(
128
)))),
((
int
)(((
byte
)(
128
)))),
((
int
)(((
byte
)(
255
)))));
this
.
btnSave
.
ForeColor
=
System
.
Drawing
.
Color
.
FromArgb
(((
int
)(((
byte
)(
128
)))),
((
int
)(((
byte
)(
128
)))),
((
int
)(((
byte
)(
255
)))));
this
.
btnSave
.
Location
=
new
System
.
Drawing
.
Point
(
0
,
0
);
this
.
btnSave
.
Location
=
new
System
.
Drawing
.
Point
(
0
,
0
);
this
.
btnSave
.
Margin
=
new
System
.
Windows
.
Forms
.
Padding
(
4
);
this
.
btnSave
.
Name
=
"btnSave"
;
this
.
btnSave
.
Name
=
"btnSave"
;
this
.
btnSave
.
Size
=
new
System
.
Drawing
.
Size
(
450
,
146
);
this
.
btnSave
.
Size
=
new
System
.
Drawing
.
Size
(
346
,
100
);
this
.
btnSave
.
TabIndex
=
5
;
this
.
btnSave
.
TabIndex
=
5
;
this
.
btnSave
.
Text
=
"保存"
;
this
.
btnSave
.
Text
=
"保存"
;
this
.
btnSave
.
UseVisualStyleBackColor
=
false
;
this
.
btnSave
.
UseVisualStyleBackColor
=
false
;
...
@@ -74,36 +76,49 @@
...
@@ -74,36 +76,49 @@
this
.
btnCancel
.
BackColor
=
System
.
Drawing
.
SystemColors
.
ButtonHighlight
;
this
.
btnCancel
.
BackColor
=
System
.
Drawing
.
SystemColors
.
ButtonHighlight
;
this
.
btnCancel
.
Dock
=
System
.
Windows
.
Forms
.
DockStyle
.
Right
;
this
.
btnCancel
.
Dock
=
System
.
Windows
.
Forms
.
DockStyle
.
Right
;
this
.
btnCancel
.
Font
=
new
System
.
Drawing
.
Font
(
"宋体"
,
25F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
btnCancel
.
Font
=
new
System
.
Drawing
.
Font
(
"宋体"
,
25F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
btnCancel
.
Location
=
new
System
.
Drawing
.
Point
(
450
,
0
);
this
.
btnCancel
.
Location
=
new
System
.
Drawing
.
Point
(
346
,
0
);
this
.
btnCancel
.
Margin
=
new
System
.
Windows
.
Forms
.
Padding
(
4
);
this
.
btnCancel
.
Name
=
"btnCancel"
;
this
.
btnCancel
.
Name
=
"btnCancel"
;
this
.
btnCancel
.
Size
=
new
System
.
Drawing
.
Size
(
357
,
146
);
this
.
btnCancel
.
Size
=
new
System
.
Drawing
.
Size
(
238
,
100
);
this
.
btnCancel
.
TabIndex
=
4
;
this
.
btnCancel
.
TabIndex
=
4
;
this
.
btnCancel
.
Text
=
"取消"
;
this
.
btnCancel
.
Text
=
"取消"
;
this
.
btnCancel
.
UseVisualStyleBackColor
=
false
;
this
.
btnCancel
.
UseVisualStyleBackColor
=
false
;
this
.
btnCancel
.
Click
+=
new
System
.
EventHandler
(
this
.
btnCancel_Click
);
this
.
btnCancel
.
Click
+=
new
System
.
EventHandler
(
this
.
btnCancel_Click
);
//
//
// plImage
//
this
.
plImage
.
BackgroundImageLayout
=
System
.
Windows
.
Forms
.
ImageLayout
.
Center
;
this
.
plImage
.
Controls
.
Add
(
this
.
imgResizer
);
this
.
plImage
.
Dock
=
System
.
Windows
.
Forms
.
DockStyle
.
Fill
;
this
.
plImage
.
Location
=
new
System
.
Drawing
.
Point
(
0
,
0
);
this
.
plImage
.
Name
=
"plImage"
;
this
.
plImage
.
Size
=
new
System
.
Drawing
.
Size
(
584
,
391
);
this
.
plImage
.
TabIndex
=
2
;
//
// imgResizer
// imgResizer
//
//
this
.
imgResizer
.
BackColor
=
System
.
Drawing
.
Color
.
Transparent
;
this
.
imgResizer
.
BackColor
=
System
.
Drawing
.
Color
.
Transparent
;
this
.
imgResizer
.
Location
=
new
System
.
Drawing
.
Point
(
61
,
37
);
this
.
imgResizer
.
Location
=
new
System
.
Drawing
.
Point
(
79
,
40
);
this
.
imgResizer
.
Margin
=
new
System
.
Windows
.
Forms
.
Padding
(
2
);
this
.
imgResizer
.
Name
=
"imgResizer"
;
this
.
imgResizer
.
Name
=
"imgResizer"
;
this
.
imgResizer
.
Size
=
new
System
.
Drawing
.
Size
(
681
,
626
);
this
.
imgResizer
.
Size
=
new
System
.
Drawing
.
Size
(
430
,
307
);
this
.
imgResizer
.
TabIndex
=
1
;
this
.
imgResizer
.
TabIndex
=
1
;
this
.
imgResizer
.
Text
=
"imgResizer"
;
this
.
imgResizer
.
Text
=
"imgResizer"
;
//
//
// FrmImageEditor
// FrmImageEditor
//
//
this
.
AutoScaleDimensions
=
new
System
.
Drawing
.
SizeF
(
9F
,
18
F
);
this
.
AutoScaleDimensions
=
new
System
.
Drawing
.
SizeF
(
6F
,
12
F
);
this
.
AutoScaleMode
=
System
.
Windows
.
Forms
.
AutoScaleMode
.
Font
;
this
.
AutoScaleMode
=
System
.
Windows
.
Forms
.
AutoScaleMode
.
Font
;
this
.
ClientSize
=
new
System
.
Drawing
.
Size
(
807
,
86
1
);
this
.
ClientSize
=
new
System
.
Drawing
.
Size
(
584
,
49
1
);
this
.
Controls
.
Add
(
this
.
imgResizer
);
this
.
Controls
.
Add
(
this
.
plImage
);
this
.
Controls
.
Add
(
this
.
plControl
);
this
.
Controls
.
Add
(
this
.
plControl
);
this
.
Icon
=
((
System
.
Drawing
.
Icon
)(
resources
.
GetObject
(
"$this.Icon"
)));
this
.
Icon
=
((
System
.
Drawing
.
Icon
)(
resources
.
GetObject
(
"$this.Icon"
)));
this
.
Margin
=
new
System
.
Windows
.
Forms
.
Padding
(
2
,
2
,
2
,
2
);
this
.
MinimumSize
=
new
System
.
Drawing
.
Size
(
600
,
530
);
this
.
Name
=
"FrmImageEditor"
;
this
.
Name
=
"FrmImageEditor"
;
this
.
Text
=
"图片裁剪"
;
this
.
Text
=
"图片裁剪"
;
this
.
Load
+=
new
System
.
EventHandler
(
this
.
FrmImageEditor_Load
);
this
.
Load
+=
new
System
.
EventHandler
(
this
.
FrmImageEditor_Load
);
this
.
plControl
.
ResumeLayout
(
false
);
this
.
plControl
.
ResumeLayout
(
false
);
this
.
plImage
.
ResumeLayout
(
false
);
this
.
ResumeLayout
(
false
);
this
.
ResumeLayout
(
false
);
}
}
...
@@ -115,5 +130,6 @@
...
@@ -115,5 +130,6 @@
private
System
.
Windows
.
Forms
.
Button
btnSave
;
private
System
.
Windows
.
Forms
.
Button
btnSave
;
private
System
.
Windows
.
Forms
.
Button
btnCancel
;
private
System
.
Windows
.
Forms
.
Button
btnCancel
;
private
Controls
.
ImageResizer
imgResizer
;
private
Controls
.
ImageResizer
imgResizer
;
private
System
.
Windows
.
Forms
.
Panel
plImage
;
}
}
}
}
\ No newline at end of file
Src/FrmImageEditor.cs
View file @
002a27c7
...
@@ -49,7 +49,8 @@ namespace Kivii.Sample.ImageUploader
...
@@ -49,7 +49,8 @@ namespace Kivii.Sample.ImageUploader
private
void
FrmImageEditor_Load
(
object
sender
,
EventArgs
e
)
private
void
FrmImageEditor_Load
(
object
sender
,
EventArgs
e
)
{
{
this
.
BackgroundImage
=
backgroundImage
;
this
.
plImage
.
BackgroundImage
=
backgroundImage
;
this
.
plImage
.
BackgroundImageLayout
=
ImageLayout
.
Center
;
ImgEdited
=
backgroundImage
;
ImgEdited
=
backgroundImage
;
}
}
private
void
btnCancel_Click
(
object
sender
,
EventArgs
e
)
private
void
btnCancel_Click
(
object
sender
,
EventArgs
e
)
...
@@ -59,10 +60,10 @@ namespace Kivii.Sample.ImageUploader
...
@@ -59,10 +60,10 @@ namespace Kivii.Sample.ImageUploader
private
void
btnSave_Click
(
object
sender
,
EventArgs
e
)
private
void
btnSave_Click
(
object
sender
,
EventArgs
e
)
{
{
System
.
Drawing
.
Point
p
=
new
System
.
Drawing
.
Point
(
imgResizer
.
Location
.
X
+
imgResizer
.
blank
,
imgResizer
.
Location
.
Y
+
imgResizer
.
blank
);
System
.
Drawing
.
Point
p
=
new
System
.
Drawing
.
Point
(
imgResizer
.
Location
.
X
+
imgResizer
.
blank
,
imgResizer
.
Location
.
Y
+
imgResizer
.
blank
);
Rectangle
area
=
new
Rectangle
(
p
,
imgResizer
.
area
.
Size
);
var
imgArea
=
imgResizer
.
area
;
Rectangle
area
=
new
Rectangle
(
p
,
imgArea
.
Size
);
ImgEdited
=
GetPartOfImage
(
backgroundImage
,
area
.
Width
,
area
.
Height
,
p
.
X
,
p
.
Y
);
ImgEdited
=
GetPartOfImage
(
backgroundImage
,
area
.
Width
,
area
.
Height
,
p
.
X
,
p
.
Y
);
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Bitmap
bmpFluffy
=
ImgEdited
;
Bitmap
bmpFluffy
=
ImgEdited
;
//new Bitmap(after);
//new Bitmap(after);
...
@@ -72,44 +73,16 @@ namespace Kivii.Sample.ImageUploader
...
@@ -72,44 +73,16 @@ namespace Kivii.Sample.ImageUploader
using
(
Graphics
g
=
Graphics
.
FromImage
(
bmpMask
))
using
(
Graphics
g
=
Graphics
.
FromImage
(
bmpMask
))
using
(
GraphicsPath
path
=
createRoundRect
(
using
(
GraphicsPath
path
=
createRoundRect
(
r
.
X
,
r
.
Y
,
r
.
Width
,
r
.
Height
,
0
))
r
.
X
,
r
.
Y
,
using
(
Brush
brush
=
createFluffyBrush
(
path
,
new
float
[]
{
0.0f
,
0.1f
,
1.0f
},
new
float
[]
{
0.0f
,
0.95f
,
1.0f
}))
r
.
Width
,
r
.
Height
,
0
))
using
(
Brush
brush
=
createFluffyBrush
(
path
,
new
float
[]
{
0.0f
,
0.1f
,
1.0f
},
new
float
[]
{
0.0f
,
0.95f
,
1.0f
}))
{
{
g
.
FillRectangle
(
Brushes
.
Black
,
r
);
g
.
FillRectangle
(
Brushes
.
Black
,
r
);
g
.
SmoothingMode
=
SmoothingMode
.
HighQuality
;
g
.
SmoothingMode
=
SmoothingMode
.
HighQuality
;
g
.
FillPath
(
brush
,
path
);
g
.
FillPath
(
brush
,
path
);
transferOneARGBChannelFromOneBitmapToAnother
(
bmpMask
,
bmpFluffy
,
ChannelARGB
.
Blue
,
ChannelARGB
.
Alpha
);
transferOneARGBChannelFromOneBitmapToAnother
(
bmpMask
,
bmpFluffy
,
ChannelARGB
.
Blue
,
ChannelARGB
.
Alpha
);
}
}
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Graphics
drawBk
=
Graphics
.
FromImage
(
backgroundImage
);
Graphics
drawBk
=
Graphics
.
FromImage
(
backgroundImage
);
drawBk
.
Clear
(
Color
.
FromKnownColor
(
KnownColor
.
Control
));
drawBk
.
Clear
(
Color
.
FromKnownColor
(
KnownColor
.
Control
));
drawBk
.
DrawImage
(
ImgEdited
,
area
);
drawBk
.
DrawImage
(
ImgEdited
,
area
);
...
@@ -117,11 +90,11 @@ namespace Kivii.Sample.ImageUploader
...
@@ -117,11 +90,11 @@ namespace Kivii.Sample.ImageUploader
Graphics
winGph
=
Graphics
.
FromHwnd
(
this
.
Handle
);
Graphics
winGph
=
Graphics
.
FromHwnd
(
this
.
Handle
);
winGph
.
DrawImage
(
backgroundImage
,
new
System
.
Drawing
.
Point
(
0
,
0
));
winGph
.
DrawImage
(
backgroundImage
,
new
System
.
Drawing
.
Point
(
0
,
0
));
this
.
BackgroundImage
=
backgroundImage
;
this
.
plImage
.
BackgroundImage
=
backgroundImage
;
imgResizer
.
Visible
=
false
;
imgResizer
.
Visible
=
false
;
this
.
Refresh
();
this
.
plImage
.
Refresh
();
timeImageEditor
.
Enabled
=
true
;
timeImageEditor
.
Enabled
=
true
;
}
}
...
...
Src/FrmMain.Designer.cs
View file @
002a27c7
This diff is collapsed.
Click to expand it.
Src/FrmMain.cs
View file @
002a27c7
...
@@ -872,26 +872,32 @@ namespace Kivii.Sample.ImageUploader
...
@@ -872,26 +872,32 @@ namespace Kivii.Sample.ImageUploader
MessageBox
.
Show
(
"当前照片已上传,无法编辑"
);
MessageBox
.
Show
(
"当前照片已上传,无法编辑"
);
return
;
return
;
}
}
FrmImageEditor
imageEditor
=
new
FrmImageEditor
();
FrmImageEditor
frm
=
new
FrmImageEditor
();
Bitmap
bmp
=
currentPhoto
.
Image
;
Bitmap
bmp
=
currentPhoto
.
Image
;
imageEditor
.
backgroundImage
=
bmp
;
frm
.
backgroundImage
=
bmp
;
if
(
bmp
.
Width
>
1280
)
frm
.
Width
=
bmp
.
Width
;
imageEditor
.
Width
=
1280
;
frm
.
Height
=
bmp
.
Height
+
120
;
else
frm
.
Owner
=
this
;
imageEditor
.
Width
=
bmp
.
Width
;
if
(
bmp
.
Height
>
1024
)
imageEditor
.
Height
=
1024
;
else
imageEditor
.
Height
=
bmp
.
Height
+
20
;
imageEditor
.
Owner
=
this
;
imageEditor
.
ShowDialog
();
frm
.
ShowDialog
();
}
}
public
void
setBackgroundImage
(
Bitmap
backgroundImage
)
public
void
setBackgroundImage
(
Bitmap
backgroundImage
)
{
{
this
.
BackgroundImage
=
backgroundImage
;
//currentPhoto.Image = backgroundImage;
int
index
=
0
;
var
photo
=
photos
.
FirstOrDefault
(
o
=>
o
.
Image
==
currentPhoto
.
Image
);
if
(
photo
!=
null
)
{
index
=
photos
.
IndexOf
(
photo
);
if
(
index
<=
-
1
)
index
=
0
;
deleteSnapshot
(
photo
);
}
var
editedPhoto
=
new
DbFile
(
backgroundImage
,
currentPhoto
.
Name
);
addSnapshot
(
editedPhoto
,
index
);
showSnapshot
(
editedPhoto
);
}
}
}
}
}
}
Src/Kivii.Client.Sample.ImageUploader.V4.5.csproj
View file @
002a27c7
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
<ProjectGuid>
{9C9A89CF-F17F-4607-A89E-5E07C184EB1E}
</ProjectGuid>
<ProjectGuid>
{9C9A89CF-F17F-4607-A89E-5E07C184EB1E}
</ProjectGuid>
<OutputType>
WinExe
</OutputType>
<OutputType>
WinExe
</OutputType>
<RootNamespace>
Kivii.Sample.ImageUploader
</RootNamespace>
<RootNamespace>
Kivii.Sample.ImageUploader
</RootNamespace>
<AssemblyName>
Kivii.Sample.ImageUploader
</AssemblyName>
<AssemblyName>
样品拍照采集
</AssemblyName>
<TargetFrameworkVersion>
v4.5
</TargetFrameworkVersion>
<TargetFrameworkVersion>
v4.5
</TargetFrameworkVersion>
<FileAlignment>
512
</FileAlignment>
<FileAlignment>
512
</FileAlignment>
<Deterministic>
true
</Deterministic>
<Deterministic>
true
</Deterministic>
...
...
Src/Properties/AssemblyInfo.cs
View file @
002a27c7
...
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
...
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("5.4.2024.5
28
0")]
[assembly: AssemblyVersion("5.4.2024.5
30
0")]
[assembly: AssemblyFileVersion("5.4.2024.5
28
0")]
[assembly: AssemblyFileVersion("5.4.2024.5
30
0")]
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment