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
a46c1f78
Commit
a46c1f78
authored
Jul 17, 2012
by
Dmitry Timoshkov
Committed by
Alexandre Julliard
Jul 17, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gdiplus: Use public ColorPalette structure to store image palette.
parent
85d3d760
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
53 additions
and
62 deletions
+53
-62
gdiplus_private.h
dlls/gdiplus/gdiplus_private.h
+1
-4
graphics.c
dlls/gdiplus/graphics.c
+3
-5
image.c
dlls/gdiplus/image.c
+48
-49
metafile.c
dlls/gdiplus/metafile.c
+1
-4
No files found.
dlls/gdiplus/gdiplus_private.h
View file @
a46c1f78
...
...
@@ -267,10 +267,7 @@ struct GpImage{
GUID
format
;
UINT
flags
;
UINT
frame_count
,
current_frame
;
UINT
palette_flags
;
UINT
palette_count
;
UINT
palette_size
;
ARGB
*
palette_entries
;
ColorPalette
*
palette
;
REAL
xres
,
yres
;
};
...
...
dlls/gdiplus/graphics.c
View file @
a46c1f78
...
...
@@ -2318,10 +2318,7 @@ GpStatus WINGDIPAPI GdipCreateMetafileFromEmf(HENHMETAFILE hemf, BOOL delete,
(
*
metafile
)
->
image
.
type
=
ImageTypeMetafile
;
memcpy
(
&
(
*
metafile
)
->
image
.
format
,
&
ImageFormatWMF
,
sizeof
(
GUID
));
(
*
metafile
)
->
image
.
palette_flags
=
0
;
(
*
metafile
)
->
image
.
palette_count
=
0
;
(
*
metafile
)
->
image
.
palette_size
=
0
;
(
*
metafile
)
->
image
.
palette_entries
=
NULL
;
(
*
metafile
)
->
image
.
palette
=
NULL
;
(
*
metafile
)
->
image
.
xres
=
(
REAL
)
copy
->
szlDevice
.
cx
;
(
*
metafile
)
->
image
.
yres
=
(
REAL
)
copy
->
szlDevice
.
cy
;
(
*
metafile
)
->
bounds
.
X
=
(
REAL
)
copy
->
rclBounds
.
left
;
...
...
@@ -3276,7 +3273,8 @@ GpStatus WINGDIPAPI GdipDrawImagePointsRect(GpGraphics *graphics, GpImage *image
convert_pixels
(
bitmap
->
width
,
bitmap
->
height
,
bitmap
->
width
*
4
,
temp_bits
,
dst_format
,
bitmap
->
stride
,
bitmap
->
bits
,
bitmap
->
format
,
bitmap
->
image
.
palette_entries
);
bitmap
->
stride
,
bitmap
->
bits
,
bitmap
->
format
,
bitmap
->
image
.
palette
?
bitmap
->
image
.
palette
->
Entries
:
NULL
);
}
else
{
...
...
dlls/gdiplus/image.c
View file @
a46c1f78
...
...
@@ -290,7 +290,7 @@ GpStatus WINGDIPAPI GdipBitmapGetPixel(GpBitmap* bitmap, INT x, INT y,
}
if
(
bitmap
->
format
&
PixelFormatIndexed
)
*
color
=
bitmap
->
image
.
palette
_e
ntries
[
index
];
*
color
=
bitmap
->
image
.
palette
->
E
ntries
[
index
];
else
*
color
=
a
<<
24
|
r
<<
16
|
g
<<
8
|
b
;
...
...
@@ -311,8 +311,8 @@ static inline UINT get_palette_index(BYTE r, BYTE g, BYTE b, BYTE a, GpBitmap* b
tables and thus may actually be slower if this method is called only few times per
every image.
*/
for
(
i
=
0
;
i
<
bitmap
->
image
.
palette
_size
;
i
++
)
{
ARGB
color
=
bitmap
->
image
.
palette
_e
ntries
[
i
];
for
(
i
=
0
;
i
<
bitmap
->
image
.
palette
->
Count
;
i
++
)
{
ARGB
color
=
bitmap
->
image
.
palette
->
E
ntries
[
i
];
distance
=
abs
(
b
-
(
color
&
0xff
))
+
abs
(
g
-
(
color
>>
8
&
0xff
))
+
abs
(
r
-
(
color
>>
16
&
0xff
))
+
abs
(
a
-
(
color
>>
24
&
0xff
));
if
(
distance
<
best_distance
)
{
best_distance
=
distance
;
...
...
@@ -1012,7 +1012,7 @@ GpStatus WINGDIPAPI GdipBitmapLockBits(GpBitmap* bitmap, GDIPCONST GpRect* rect,
lockeddata
->
Stride
,
lockeddata
->
Scan0
,
format
,
bitmap
->
stride
,
bitmap
->
bits
+
bitmap
->
stride
*
act_rect
.
Y
+
PIXELFORMATBPP
(
bitmap
->
format
)
*
act_rect
.
X
/
8
,
bitmap
->
format
,
bitmap
->
image
.
palette
_entries
);
bitmap
->
format
,
bitmap
->
image
.
palette
?
bitmap
->
image
.
palette
->
Entries
:
NULL
);
if
(
stat
!=
Ok
)
{
...
...
@@ -1770,10 +1770,7 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromScan0(INT width, INT height, INT stride,
(
*
bitmap
)
->
image
.
flags
=
ImageFlagsNone
;
(
*
bitmap
)
->
image
.
frame_count
=
1
;
(
*
bitmap
)
->
image
.
current_frame
=
0
;
(
*
bitmap
)
->
image
.
palette_flags
=
0
;
(
*
bitmap
)
->
image
.
palette_count
=
0
;
(
*
bitmap
)
->
image
.
palette_size
=
0
;
(
*
bitmap
)
->
image
.
palette_entries
=
NULL
;
(
*
bitmap
)
->
image
.
palette
=
NULL
;
(
*
bitmap
)
->
image
.
xres
=
xres
;
(
*
bitmap
)
->
image
.
yres
=
yres
;
(
*
bitmap
)
->
width
=
width
;
...
...
@@ -1796,29 +1793,30 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromScan0(INT width, INT height, INT stride,
format
==
PixelFormat4bppIndexed
||
format
==
PixelFormat8bppIndexed
)
{
(
*
bitmap
)
->
image
.
palette_size
=
(
*
bitmap
)
->
image
.
palette_count
=
1
<<
PIXELFORMATBPP
(
format
);
(
*
bitmap
)
->
image
.
palette_entries
=
GdipAlloc
(
sizeof
(
ARGB
)
*
((
*
bitmap
)
->
image
.
palette_size
));
(
*
bitmap
)
->
image
.
palette
=
GdipAlloc
(
sizeof
(
UINT
)
*
2
+
sizeof
(
ARGB
)
*
(
1
<<
PIXELFORMATBPP
(
format
)));
if
(
!
(
*
bitmap
)
->
image
.
palette
_entries
)
if
(
!
(
*
bitmap
)
->
image
.
palette
)
{
GdipDisposeImage
(
&
(
*
bitmap
)
->
image
);
*
bitmap
=
NULL
;
return
OutOfMemory
;
}
(
*
bitmap
)
->
image
.
palette
->
Count
=
1
<<
PIXELFORMATBPP
(
format
);
if
(
format
==
PixelFormat1bppIndexed
)
{
(
*
bitmap
)
->
image
.
palette
_f
lags
=
PaletteFlagsGrayScale
;
(
*
bitmap
)
->
image
.
palette
_e
ntries
[
0
]
=
0xff000000
;
(
*
bitmap
)
->
image
.
palette
_e
ntries
[
1
]
=
0xffffffff
;
(
*
bitmap
)
->
image
.
palette
->
F
lags
=
PaletteFlagsGrayScale
;
(
*
bitmap
)
->
image
.
palette
->
E
ntries
[
0
]
=
0xff000000
;
(
*
bitmap
)
->
image
.
palette
->
E
ntries
[
1
]
=
0xffffffff
;
}
else
{
if
(
format
==
PixelFormat8bppIndexed
)
(
*
bitmap
)
->
image
.
palette
_f
lags
=
PaletteFlagsHalftone
;
(
*
bitmap
)
->
image
.
palette
->
F
lags
=
PaletteFlagsHalftone
;
generate_halftone_palette
((
*
bitmap
)
->
image
.
palette
_e
ntries
,
(
*
bitmap
)
->
image
.
palette
_c
ount
);
generate_halftone_palette
((
*
bitmap
)
->
image
.
palette
->
E
ntries
,
(
*
bitmap
)
->
image
.
palette
->
C
ount
);
}
}
...
...
@@ -1979,13 +1977,11 @@ static void move_bitmap(GpBitmap *dst, GpBitmap *src, BOOL clobber_palette)
if
(
clobber_palette
)
{
GdipFree
(
dst
->
image
.
palette_entries
);
dst
->
image
.
palette_flags
=
src
->
image
.
palette_flags
;
dst
->
image
.
palette_count
=
src
->
image
.
palette_count
;
dst
->
image
.
palette_entries
=
src
->
image
.
palette_entries
;
GdipFree
(
dst
->
image
.
palette
);
dst
->
image
.
palette
=
src
->
image
.
palette
;
}
else
GdipFree
(
src
->
image
.
palette
_entries
);
GdipFree
(
src
->
image
.
palette
);
dst
->
image
.
xres
=
src
->
image
.
xres
;
dst
->
image
.
yres
=
src
->
image
.
yres
;
...
...
@@ -2048,7 +2044,7 @@ static GpStatus free_image_data(GpImage *image)
IPicture_Release
(
image
->
picture
);
if
(
image
->
stream
)
IStream_Release
(
image
->
stream
);
GdipFree
(
image
->
palette
_entries
);
GdipFree
(
image
->
palette
);
return
Ok
;
}
...
...
@@ -2237,10 +2233,10 @@ GpStatus WINGDIPAPI GdipGetImagePaletteSize(GpImage *image, INT *size)
if
(
!
image
||
!
size
)
return
InvalidParameter
;
if
(
image
->
palette_c
ount
==
0
)
if
(
!
image
->
palette
||
image
->
palette
->
C
ount
==
0
)
*
size
=
sizeof
(
ColorPalette
);
else
*
size
=
sizeof
(
UINT
)
*
2
+
sizeof
(
ARGB
)
*
image
->
palette
_c
ount
;
*
size
=
sizeof
(
UINT
)
*
2
+
sizeof
(
ARGB
)
*
image
->
palette
->
C
ount
;
TRACE
(
"<-- %u
\n
"
,
*
size
);
...
...
@@ -3065,7 +3061,7 @@ end:
bitmap
->
image
.
current_frame
=
active_frame
;
bitmap
->
image
.
stream
=
stream
;
if
(
IsEqualGUID
(
&
wic_format
,
&
GUID_WICPixelFormatBlackWhite
))
bitmap
->
image
.
palette
_f
lags
=
0
;
bitmap
->
image
.
palette
->
F
lags
=
0
;
/* Pin the source stream */
IStream_AddRef
(
stream
);
}
...
...
@@ -3140,10 +3136,7 @@ static GpStatus decode_image_olepicture_metafile(IStream* stream, REFCLSID clsid
(
*
image
)
->
flags
=
ImageFlagsNone
;
(
*
image
)
->
frame_count
=
1
;
(
*
image
)
->
current_frame
=
0
;
(
*
image
)
->
palette_flags
=
0
;
(
*
image
)
->
palette_count
=
0
;
(
*
image
)
->
palette_size
=
0
;
(
*
image
)
->
palette_entries
=
NULL
;
(
*
image
)
->
palette
=
NULL
;
TRACE
(
"<-- %p
\n
"
,
*
image
);
...
...
@@ -3598,21 +3591,32 @@ GpStatus WINGDIPAPI GdipSaveAdd(GpImage *image, GDIPCONST EncoderParameters *par
*/
GpStatus
WINGDIPAPI
GdipGetImagePalette
(
GpImage
*
image
,
ColorPalette
*
palette
,
INT
size
)
{
INT
count
;
TRACE
(
"(%p,%p,%i)
\n
"
,
image
,
palette
,
size
);
if
(
!
image
||
!
palette
)
return
InvalidParameter
;
if
(
size
<
(
sizeof
(
UINT
)
*
2
+
sizeof
(
ARGB
)
*
image
->
palette_count
))
count
=
image
->
palette
?
image
->
palette
->
Count
:
0
;
if
(
size
<
(
sizeof
(
UINT
)
*
2
+
sizeof
(
ARGB
)
*
count
))
{
TRACE
(
"<-- InsufficientBuffer
\n
"
);
return
InsufficientBuffer
;
}
palette
->
Flags
=
image
->
palette_flags
;
palette
->
Count
=
image
->
palette_count
;
memcpy
(
palette
->
Entries
,
image
->
palette_entries
,
sizeof
(
ARGB
)
*
image
->
palette_count
);
if
(
image
->
palette
)
{
palette
->
Flags
=
image
->
palette
->
Flags
;
palette
->
Count
=
image
->
palette
->
Count
;
memcpy
(
palette
->
Entries
,
image
->
palette
->
Entries
,
sizeof
(
ARGB
)
*
image
->
palette
->
Count
);
}
else
{
palette
->
Flags
=
0
;
palette
->
Count
=
0
;
}
return
Ok
;
}
...
...
@@ -3622,26 +3626,21 @@ GpStatus WINGDIPAPI GdipGetImagePalette(GpImage *image, ColorPalette *palette, I
GpStatus
WINGDIPAPI
GdipSetImagePalette
(
GpImage
*
image
,
GDIPCONST
ColorPalette
*
palette
)
{
ColorPalette
*
new_palette
;
TRACE
(
"(%p,%p)
\n
"
,
image
,
palette
);
if
(
!
image
||
!
palette
||
palette
->
Count
>
256
)
return
InvalidParameter
;
if
(
palette
->
Count
>
image
->
palette_size
)
{
ARGB
*
new_palette
;
new_palette
=
GdipAlloc
(
sizeof
(
ARGB
)
*
palette
->
Count
);
if
(
!
new_palette
)
return
OutOfMemory
;
GdipFree
(
image
->
palette_entries
);
image
->
palette_entries
=
new_palette
;
image
->
palette_size
=
palette
->
Count
;
}
new_palette
=
GdipAlloc
(
2
*
sizeof
(
UINT
)
+
palette
->
Count
*
sizeof
(
ARGB
));
if
(
!
new_palette
)
return
OutOfMemory
;
image
->
palette_flags
=
palette
->
Flags
;
image
->
palette_count
=
palette
->
Count
;
memcpy
(
image
->
palette_entries
,
palette
->
Entries
,
sizeof
(
ARGB
)
*
palette
->
Count
);
GdipFree
(
image
->
palette
);
image
->
palette
=
new_palette
;
image
->
palette
->
Flags
=
palette
->
Flags
;
image
->
palette
->
Count
=
palette
->
Count
;
memcpy
(
image
->
palette
->
Entries
,
palette
->
Entries
,
sizeof
(
ARGB
)
*
palette
->
Count
);
return
Ok
;
}
...
...
dlls/gdiplus/metafile.c
View file @
a46c1f78
...
...
@@ -232,10 +232,7 @@ GpStatus WINGDIPAPI GdipRecordMetafile(HDC hdc, EmfType type, GDIPCONST GpRectF
(
*
metafile
)
->
image
.
type
=
ImageTypeMetafile
;
(
*
metafile
)
->
image
.
picture
=
NULL
;
(
*
metafile
)
->
image
.
flags
=
ImageFlagsNone
;
(
*
metafile
)
->
image
.
palette_flags
=
0
;
(
*
metafile
)
->
image
.
palette_count
=
0
;
(
*
metafile
)
->
image
.
palette_size
=
0
;
(
*
metafile
)
->
image
.
palette_entries
=
NULL
;
(
*
metafile
)
->
image
.
palette
=
NULL
;
(
*
metafile
)
->
bounds
=
*
frameRect
;
(
*
metafile
)
->
unit
=
frameUnit
;
(
*
metafile
)
->
metafile_type
=
type
;
...
...
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