Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
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
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
d5fce697
Commit
d5fce697
authored
Jun 13, 2005
by
Huw Davies
Committed by
Alexandre Julliard
Jun 13, 2005
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
When loading a bitmap we should stretch the image to the requested
size.
parent
6b1e80cb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
66 additions
and
53 deletions
+66
-53
cursoricon.c
dlls/user/cursoricon.c
+66
-53
No files found.
dlls/user/cursoricon.c
View file @
d5fce697
...
...
@@ -2059,15 +2059,22 @@ static void DIB_FixColorsToLoadflags(BITMAPINFO * bmi, UINT loadflags, BYTE pix)
/**********************************************************************
* BITMAP_Load
*/
static
HBITMAP
BITMAP_Load
(
HINSTANCE
instance
,
LPCWSTR
name
,
UINT
loadflags
)
static
HBITMAP
BITMAP_Load
(
HINSTANCE
instance
,
LPCWSTR
name
,
INT
desiredx
,
INT
desiredy
,
UINT
loadflags
)
{
HBITMAP
hbitmap
=
0
;
HBITMAP
hbitmap
=
0
,
orig_bm
;
HRSRC
hRsrc
;
HGLOBAL
handle
;
char
*
ptr
=
NULL
;
BITMAPINFO
*
info
,
*
fix_info
=
NULL
;
HGLOBAL
hFix
;
BITMAPINFO
*
info
,
*
fix_info
=
NULL
,
*
scaled_info
=
NULL
;
int
size
;
BYTE
pix
;
char
*
bits
;
LONG
width
,
height
,
new_width
,
new_height
;
WORD
bpp_dummy
;
DWORD
compr_dummy
;
INT
bm_type
;
HDC
screen_mem_dc
=
NULL
;
if
(
!
(
loadflags
&
LR_LOADFROMFILE
))
{
...
...
@@ -2090,62 +2097,68 @@ static HBITMAP BITMAP_Load( HINSTANCE instance, LPCWSTR name, UINT loadflags )
}
size
=
bitmap_info_size
(
info
,
DIB_RGB_COLORS
);
if
((
hFix
=
GlobalAlloc
(
0
,
size
)))
fix_info
=
GlobalLock
(
hFix
);
fix_info
=
HeapAlloc
(
GetProcessHeap
(),
0
,
size
);
scaled_info
=
HeapAlloc
(
GetProcessHeap
(),
0
,
size
);
if
(
fix_info
)
{
BYTE
pix
;
if
(
!
fix_info
||
!
scaled_info
)
goto
end
;
memcpy
(
fix_info
,
info
,
size
)
;
memcpy
(
fix_info
,
info
,
size
);
pix
=
*
((
LPBYTE
)
info
+
size
);
DIB_FixColorsToLoadflags
(
fix_info
,
loadflags
,
pix
);
if
(
!
screen_dc
)
screen_dc
=
CreateDCW
(
DISPLAYW
,
NULL
,
NULL
,
NULL
);
pix
=
*
((
LPBYTE
)
info
+
size
);
DIB_FixColorsToLoadflags
(
fix_info
,
loadflags
,
pix
);
if
(
screen_dc
)
{
char
*
bits
=
(
char
*
)
info
+
size
;
if
(
loadflags
&
LR_CREATEDIBSECTION
)
{
DIBSECTION
dib
;
fix_info
->
bmiHeader
.
biCompression
=
0
;
/* DIBSection can't be compressed */
hbitmap
=
CreateDIBSection
(
screen_dc
,
fix_info
,
DIB_RGB_COLORS
,
NULL
,
0
,
0
);
GetObjectA
(
hbitmap
,
sizeof
(
DIBSECTION
),
&
dib
);
SetDIBits
(
screen_dc
,
hbitmap
,
0
,
dib
.
dsBm
.
bmHeight
,
bits
,
info
,
DIB_RGB_COLORS
);
}
else
{
/* If it's possible, create a monochrome bitmap */
memcpy
(
scaled_info
,
fix_info
,
size
);
bm_type
=
DIB_GetBitmapInfo
(
&
fix_info
->
bmiHeader
,
&
width
,
&
height
,
&
bpp_dummy
,
&
compr_dummy
);
if
(
desiredx
!=
0
)
new_width
=
desiredx
;
else
new_width
=
width
;
LONG
width
;
LONG
height
;
WORD
bpp
;
DWORD
compr
;
if
(
desiredy
!=
0
)
new_height
=
height
>
0
?
desiredy
:
-
desiredy
;
else
new_height
=
height
;
if
(
DIB_GetBitmapInfo
(
&
fix_info
->
bmiHeader
,
&
width
,
&
height
,
&
bpp
,
&
compr
)
!=
-
1
)
{
if
(
width
<
0
)
TRACE
(
"Bitmap has a negative width
\n
"
);
else
{
/* Top-down DIBs have a negative height */
if
(
height
<
0
)
height
=
-
height
;
TRACE
(
"width=%ld, height=%ld, bpp=%u, compr=%lu
\n
"
,
width
,
height
,
bpp
,
compr
);
if
(
is_dib_monochrome
(
fix_info
))
hbitmap
=
CreateBitmap
(
width
,
height
,
1
,
1
,
NULL
);
else
hbitmap
=
CreateCompatibleBitmap
(
screen_dc
,
width
,
height
);
SetDIBits
(
screen_dc
,
hbitmap
,
0
,
height
,
bits
,
fix_info
,
DIB_RGB_COLORS
);
}
}
}
}
if
(
bm_type
==
0
)
{
BITMAPCOREHEADER
*
core
=
(
BITMAPCOREHEADER
*
)
&
scaled_info
->
bmiHeader
;
core
->
bcWidth
=
new_width
;
core
->
bcHeight
=
new_height
;
}
else
{
scaled_info
->
bmiHeader
.
biWidth
=
new_width
;
scaled_info
->
bmiHeader
.
biHeight
=
new_height
;
}
if
(
new_height
<
0
)
new_height
=
-
new_height
;
if
(
!
screen_dc
)
screen_dc
=
CreateDCW
(
DISPLAYW
,
NULL
,
NULL
,
NULL
);
if
(
!
(
screen_mem_dc
=
CreateCompatibleDC
(
screen_dc
)))
goto
end
;
bits
=
(
char
*
)
info
+
size
;
GlobalUnlock
(
hFix
);
GlobalFree
(
hFix
);
if
(
loadflags
&
LR_CREATEDIBSECTION
)
{
scaled_info
->
bmiHeader
.
biCompression
=
0
;
/* DIBSection can't be compressed */
hbitmap
=
CreateDIBSection
(
screen_dc
,
scaled_info
,
DIB_RGB_COLORS
,
NULL
,
0
,
0
);
}
else
{
if
(
is_dib_monochrome
(
fix_info
))
hbitmap
=
CreateBitmap
(
new_width
,
new_height
,
1
,
1
,
NULL
);
else
hbitmap
=
CreateCompatibleBitmap
(
screen_dc
,
new_width
,
new_height
);
}
orig_bm
=
SelectObject
(
screen_mem_dc
,
hbitmap
);
StretchDIBits
(
screen_mem_dc
,
0
,
0
,
new_width
,
new_height
,
0
,
0
,
width
,
height
,
bits
,
fix_info
,
DIB_RGB_COLORS
,
SRCCOPY
);
SelectObject
(
screen_mem_dc
,
orig_bm
);
end:
if
(
screen_mem_dc
)
DeleteDC
(
screen_mem_dc
);
HeapFree
(
GetProcessHeap
(),
0
,
scaled_info
);
HeapFree
(
GetProcessHeap
(),
0
,
fix_info
);
if
(
loadflags
&
LR_LOADFROMFILE
)
UnmapViewOfFile
(
ptr
);
return
hbitmap
;
...
...
@@ -2231,7 +2244,7 @@ HANDLE WINAPI LoadImageW( HINSTANCE hinst, LPCWSTR name, UINT type,
if
(
loadflags
&
LR_LOADFROMFILE
)
loadflags
&=
~
LR_SHARED
;
switch
(
type
)
{
case
IMAGE_BITMAP
:
return
BITMAP_Load
(
hinst
,
name
,
loadflags
);
return
BITMAP_Load
(
hinst
,
name
,
desiredx
,
desiredy
,
loadflags
);
case
IMAGE_ICON
:
if
(
!
screen_dc
)
screen_dc
=
CreateDCW
(
DISPLAYW
,
NULL
,
NULL
,
NULL
);
...
...
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