HGGitLab
Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
app
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
CI / CD Analytics
Repository Analytics
Value Stream Analytics
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
luoliangyi
app
Commits
17fd7e6d
Commit
17fd7e6d
authored
Mar 19, 2022
by
luoliangyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
完善缩略图控件
parent
1d53f5f9
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
110 additions
and
101 deletions
+110
-101
app/Scanner/Scanner/mainwindow.cpp
app/Scanner/Scanner/mainwindow.cpp
+4
-3
ui/HGImgThumb.cpp
ui/HGImgThumb.cpp
+82
-82
ui/HGImgThumb.hpp
ui/HGImgThumb.hpp
+10
-2
ui/HGImgView.cpp
ui/HGImgView.cpp
+14
-14
No files found.
app/Scanner/Scanner/mainwindow.cpp
View file @
17fd7e6d
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "../../../imgfmt/HGImgFmt.h"
#include <math.h>
MainWindow
::
MainWindow
(
QWidget
*
parent
)
:
QMainWindow
(
parent
)
...
...
@@ -49,9 +50,9 @@ MainWindow::MainWindow(QWidget *parent)
QImage
img2
(
"D:
\\
ImageSrc
\\
image.png"
);
m_thumb
->
setDefItemImage
(
&
img2
);
m_thumb
->
setType
(
HGImgThumb
::
ThumbType_Grid
);
m_thumb
->
setGapSize
(
2
0
);
m_thumb
->
setGapSize
(
0
);
m_thumb
->
setItemSize
(
80
);
//m_thumb->setItemTextHeight(
0);
m_thumb
->
setItemTextHeight
(
2
0
);
m_thumb
->
setScrollSize
(
20
);
m_thumb
->
setMinScrollSliderSize
(
40
);
...
...
@@ -71,7 +72,7 @@ MainWindow::MainWindow(QWidget *parent)
HGRect
vStretchRect
=
{
0
,
20
,
20
,
60
};
m_thumb
->
setVScrollSliderImage
(
&
vScrollSliderImage
,
&
vStretchRect
,
&
vScrollSliderImage
,
&
vStretchRect
,
&
vScrollSliderImage
,
&
vStretchRect
);
for
(
int
i
=
0
;
i
<
19999
;
++
i
)
for
(
int
i
=
0
;
i
<
20000
;
++
i
)
{
char
fileName
[
256
];
sprintf
(
fileName
,
"D:
\\
Pictures
\\
%d.jpg"
,
i
);
...
...
ui/HGImgThumb.cpp
View file @
17fd7e6d
This diff is collapsed.
Click to expand it.
ui/HGImgThumb.hpp
View file @
17fd7e6d
...
...
@@ -97,6 +97,14 @@ private:
bool
selected
;
};
struct
ThumbRect
{
double
left
;
double
top
;
double
right
;
double
bottom
;
};
enum
MouseStatus
{
MouseStatus_Null
=
0
,
...
...
@@ -137,7 +145,7 @@ private:
static
void
DrawImage
(
QPainter
&
painter
,
const
QRect
&
destRect
,
const
QImage
*
image
,
const
QRect
&
stretchRect
);
static
void
calcShowSize
(
int
wndWidth
,
int
wndHeight
,
int
gapSize
,
int
scrollSize
,
int
itemSize
,
int
itemTextHeight
,
ThumbType
type
,
int
itemCount
,
int
&
showWidth
,
int
&
showHeight
,
bool
&
hScroll
,
bool
&
vScroll
);
static
void
recalcShowRect
(
int
wndWidth
,
int
wndHeight
,
int
scrollSize
,
ThumbType
type
,
bool
hScroll
,
bool
vScroll
,
bool
showThumb
,
HGRectF
&
thumbRect
);
static
void
recalcShowRect
(
int
wndWidth
,
int
wndHeight
,
int
scrollSize
,
ThumbType
type
,
bool
hScroll
,
bool
vScroll
,
bool
showThumb
,
ThumbRect
&
thumbRect
);
void
locateItemEx
(
int
index
);
QPoint
getItemLoc
(
int
index
);
...
...
@@ -199,7 +207,7 @@ private:
bool
m_hScroll
;
bool
m_vScroll
;
bool
m_showThumb
;
HGRectF
m_thumbRect
;
ThumbRect
m_thumbRect
;
int
m_mousePosX
;
int
m_mousePosY
;
MouseStatus
m_mouseMoveStatus
;
...
...
ui/HGImgView.cpp
View file @
17fd7e6d
...
...
@@ -202,7 +202,7 @@ HGResult HGImgView::zoomIn(const HGPoint *pCenter)
if
(
fabs
(
fMaxWidth
-
fCurWidth
)
>
1e-3
||
fabs
(
fMaxHeight
-
fCurHeight
)
>
1e-3
)
{
if
(
fNewWidth
-
fMaxWidth
>
-
1e-3
||
fNewHeight
-
fMaxHeight
>
-
1e-3
||
(
int
)(
100.0
f
*
fNewWidth
/
(
float
)
info
.
width
+
0.5
f
)
==
(
int
)(
100.0
f
*
fMaxWidth
/
(
float
)
info
.
width
+
0.5
f
))
||
round
(
100.0
f
*
fNewWidth
/
(
float
)
info
.
width
)
==
round
(
100.0
f
*
fMaxWidth
/
(
float
)
info
.
width
))
{
fNewWidth
=
fMaxWidth
;
fNewHeight
=
fMaxHeight
;
...
...
@@ -246,7 +246,7 @@ HGResult HGImgView::zoomOut(const HGPoint *pCenter)
if
(
fabs
(
fMinWidth
-
fCurWidth
)
>
1e-3
||
fabs
(
fMinHeight
-
fCurHeight
)
>
1e-3
)
{
if
(
fNewWidth
-
fMinWidth
<
1e-3
||
fNewHeight
-
fMinHeight
<
1e-3
||
(
int
)(
100.0
f
*
fNewWidth
/
(
float
)
info
.
width
+
0.5
f
)
==
(
int
)(
100.0
f
*
fMinWidth
/
(
float
)
info
.
width
+
0.5
f
))
||
round
(
100.0
f
*
fNewWidth
/
(
float
)
info
.
width
)
==
round
(
100.0
f
*
fMinWidth
/
(
float
)
info
.
width
))
{
fNewWidth
=
fMinWidth
;
fNewHeight
=
fMinHeight
;
...
...
@@ -551,10 +551,10 @@ void HGImgView::paintEvent(QPaintEvent* e)
int
xSrc
,
ySrc
,
wSrc
,
hSrc
;
HGRect
rcShowImage
;
// 绘制的图像区域
rcShowImage
.
left
=
(
int
)(
m_showRect
.
left
+
0.5
f
);
rcShowImage
.
top
=
(
int
)(
m_showRect
.
top
+
0.5
f
);
rcShowImage
.
right
=
(
int
)(
m_showRect
.
right
+
0.5
f
);
rcShowImage
.
bottom
=
(
int
)(
m_showRect
.
bottom
+
0.5
f
);
rcShowImage
.
left
=
round
(
m_showRect
.
left
);
rcShowImage
.
top
=
round
(
m_showRect
.
top
);
rcShowImage
.
right
=
round
(
m_showRect
.
right
);
rcShowImage
.
bottom
=
round
(
m_showRect
.
bottom
);
int
nShowWidth
=
rcShowImage
.
right
-
rcShowImage
.
left
;
int
nShowHeight
=
rcShowImage
.
bottom
-
rcShowImage
.
top
;
...
...
@@ -562,11 +562,11 @@ void HGImgView::paintEvent(QPaintEvent* e)
{
float
fPixel
=
(
float
)
nImgWidth
*
(
rcWnd
.
left
-
rcShowImage
.
left
)
/
nShowWidth
;
float
fPixelR
=
(
float
)
nImgWidth
*
(
rcShowImage
.
right
-
rcWnd
.
right
)
/
nShowWidth
;
xDest
=
rcShowImage
.
left
+
(
int
)((
int
)
fPixel
*
(
float
)
nShowWidth
/
nImgWidth
+
0.5
f
);
int
xDestR
=
rcShowImage
.
right
-
(
int
)((
int
)
fPixelR
*
(
float
)
nShowWidth
/
nImgWidth
+
0.5
f
);
xDest
=
rcShowImage
.
left
+
round
((
int
)
fPixel
*
(
float
)
nShowWidth
/
nImgWidth
);
int
xDestR
=
rcShowImage
.
right
-
round
((
int
)
fPixelR
*
(
float
)
nShowWidth
/
nImgWidth
);
wDest
=
xDestR
-
xDest
;
wSrc
=
(
int
)((
float
)
nImgWidth
*
wDest
/
nShowWidth
+
0.5
f
);
xSrc
=
(
int
)((
float
)(
xDest
-
rcShowImage
.
left
)
*
nImgWidth
/
nShowWidth
+
0.5
f
);
wSrc
=
round
((
float
)
nImgWidth
*
wDest
/
nShowWidth
);
xSrc
=
round
((
float
)(
xDest
-
rcShowImage
.
left
)
*
nImgWidth
/
nShowWidth
);
}
else
{
...
...
@@ -580,11 +580,11 @@ void HGImgView::paintEvent(QPaintEvent* e)
{
float
fPixel
=
(
float
)
nImgHeight
*
(
rcWnd
.
top
-
rcShowImage
.
top
)
/
nShowHeight
;
float
fPixelB
=
(
float
)
nImgHeight
*
(
rcShowImage
.
bottom
-
rcWnd
.
bottom
)
/
nShowHeight
;
yDest
=
rcShowImage
.
top
+
(
int
)((
int
)
fPixel
*
(
float
)
nShowHeight
/
nImgHeight
+
0.5
f
);
int
yDestB
=
rcShowImage
.
bottom
-
(
int
)((
int
)
fPixelB
*
(
float
)
nShowHeight
/
nImgHeight
+
0.5
f
);
yDest
=
rcShowImage
.
top
+
round
((
int
)
fPixel
*
(
float
)
nShowHeight
/
nImgHeight
);
int
yDestB
=
rcShowImage
.
bottom
-
round
((
int
)
fPixelB
*
(
float
)
nShowHeight
/
nImgHeight
);
hDest
=
yDestB
-
yDest
;
hSrc
=
(
int
)((
float
)
nImgHeight
*
hDest
/
nShowHeight
+
0.5
f
);
ySrc
=
(
int
)((
float
)(
yDest
-
rcShowImage
.
top
)
*
nImgHeight
/
nShowHeight
+
0.5
f
);
hSrc
=
round
((
float
)
nImgHeight
*
hDest
/
nShowHeight
);
ySrc
=
round
((
float
)(
yDest
-
rcShowImage
.
top
)
*
nImgHeight
/
nShowHeight
);
}
else
{
...
...
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