Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
wine
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Package registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Lorenzo Ferrillo
wine
Commits
ee3c1790
Commit
ee3c1790
authored
14 years ago
by
Martin Petricek
Committed by
Alexandre Julliard
14 years ago
Browse files
Options
Downloads
Patches
Plain Diff
gdiplus: Support for indexed formats in GdipBitmapSetPixel.
parent
85386c2c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
dlls/gdiplus/image.c
+56
-0
56 additions, 0 deletions
dlls/gdiplus/image.c
dlls/gdiplus/tests/image.c
+3
-3
3 additions, 3 deletions
dlls/gdiplus/tests/image.c
with
59 additions
and
3 deletions
dlls/gdiplus/image.c
+
56
−
0
View file @
ee3c1790
...
...
@@ -296,6 +296,53 @@ GpStatus WINGDIPAPI GdipBitmapGetPixel(GpBitmap* bitmap, INT x, INT y,
return
Ok
;
}
static
inline
UINT
get_palette_index
(
BYTE
r
,
BYTE
g
,
BYTE
b
,
BYTE
a
,
GpBitmap
*
bitmap
)
{
BYTE
index
=
0
;
int
best_distance
=
0x7fff
;
int
distance
;
int
i
;
/* This algorithm scans entire pallete,
computes difference from desired color (all color components have equal weight)
and returns the index of color with least difference.
Note: Maybe it could be replaced with a better algorithm for better image quality
and performance, though better algorithm would probably need some pre-built lookup
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_entries
[
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
;
index
=
i
;
}
}
return
index
;
}
static
inline
void
setpixel_8bppIndexed
(
BYTE
r
,
BYTE
g
,
BYTE
b
,
BYTE
a
,
BYTE
*
row
,
UINT
x
,
GpBitmap
*
bitmap
)
{
BYTE
index
=
get_palette_index
(
r
,
g
,
b
,
a
,
bitmap
);
row
[
x
]
=
index
;
}
static
inline
void
setpixel_1bppIndexed
(
BYTE
r
,
BYTE
g
,
BYTE
b
,
BYTE
a
,
BYTE
*
row
,
UINT
x
,
GpBitmap
*
bitmap
)
{
row
[
x
/
8
]
=
(
row
[
x
/
8
]
&
~
(
1
<<
(
7
-
x
%
8
)))
|
(
get_palette_index
(
r
,
g
,
b
,
a
,
bitmap
)
<<
(
7
-
x
%
8
));
}
static
inline
void
setpixel_4bppIndexed
(
BYTE
r
,
BYTE
g
,
BYTE
b
,
BYTE
a
,
BYTE
*
row
,
UINT
x
,
GpBitmap
*
bitmap
)
{
if
(
x
&
1
)
row
[
x
/
2
]
=
(
row
[
x
/
2
]
&
0xf0
)
|
get_palette_index
(
r
,
g
,
b
,
a
,
bitmap
);
else
row
[
x
/
2
]
=
(
row
[
x
/
2
]
&
0x0f
)
|
get_palette_index
(
r
,
g
,
b
,
a
,
bitmap
)
<<
4
;
}
static
inline
void
setpixel_16bppGrayScale
(
BYTE
r
,
BYTE
g
,
BYTE
b
,
BYTE
a
,
BYTE
*
row
,
UINT
x
)
{
...
...
@@ -434,6 +481,15 @@ GpStatus WINGDIPAPI GdipBitmapSetPixel(GpBitmap* bitmap, INT x, INT y,
case
PixelFormat64bppPARGB
:
setpixel_64bppPARGB
(
r
,
g
,
b
,
a
,
row
,
x
);
break
;
case
PixelFormat8bppIndexed
:
setpixel_8bppIndexed
(
r
,
g
,
b
,
a
,
row
,
x
,
bitmap
);
break
;
case
PixelFormat4bppIndexed
:
setpixel_4bppIndexed
(
r
,
g
,
b
,
a
,
row
,
x
,
bitmap
);
break
;
case
PixelFormat1bppIndexed
:
setpixel_1bppIndexed
(
r
,
g
,
b
,
a
,
row
,
x
,
bitmap
);
break
;
default:
FIXME
(
"not implemented for format 0x%x
\n
"
,
bitmap
->
format
);
return
NotImplemented
;
...
...
This diff is collapsed.
Click to expand it.
dlls/gdiplus/tests/image.c
+
3
−
3
View file @
ee3c1790
...
...
@@ -1568,7 +1568,7 @@ static void test_palette(void)
expect
(
0xff000000
,
color
);
stat
=
GdipBitmapSetPixel
(
bitmap
,
0
,
1
,
0xffffffff
);
todo_wine
ok
((
stat
==
Ok
)
||
ok
((
stat
==
Ok
)
||
broken
(
stat
==
InvalidParameter
)
/* pre-win7 */
,
"stat=%.8x
\n
"
,
stat
);
if
(
stat
==
Ok
)
...
...
@@ -1601,7 +1601,7 @@ static void test_palette(void)
expect
(
0xff000000
,
color
);
stat
=
GdipBitmapSetPixel
(
bitmap
,
0
,
1
,
0xffff00ff
);
todo_wine
ok
((
stat
==
Ok
)
||
ok
((
stat
==
Ok
)
||
broken
(
stat
==
InvalidParameter
)
/* pre-win7 */
,
"stat=%.8x
\n
"
,
stat
);
if
(
stat
==
Ok
)
...
...
@@ -1634,7 +1634,7 @@ static void test_palette(void)
expect
(
0xff000000
,
color
);
stat
=
GdipBitmapSetPixel
(
bitmap
,
0
,
1
,
0xffcccccc
);
todo_wine
ok
((
stat
==
Ok
)
||
ok
((
stat
==
Ok
)
||
broken
(
stat
==
InvalidParameter
)
/* pre-win7 */
,
"stat=%.8x
\n
"
,
stat
);
if
(
stat
==
Ok
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment