Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
L
LCMS2 Rust Wrapper
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
Eduardo Trujillo
LCMS2 Rust Wrapper
Commits
2a83b000
Commit
2a83b000
authored
4 years ago
by
Kornel
Browse files
Options
Downloads
Patches
Plain Diff
Debug print
parent
e6eaf391
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
examples/thread.rs
+2
-1
2 additions, 1 deletion
examples/thread.rs
src/context.rs
+14
-1
14 additions, 1 deletion
src/context.rs
src/profile.rs
+14
-0
14 additions, 0 deletions
src/profile.rs
src/transform.rs
+29
-11
29 additions, 11 deletions
src/transform.rs
with
59 additions
and
13 deletions
examples/thread.rs
+
2
−
1
View file @
2a83b000
...
...
@@ -31,5 +31,6 @@ fn main() {
let
sync
=
Transform
::
new_flags_context
(
ThreadContext
::
new
(),
&
profile
,
PixelFormat
::
RGB_8
,
&
profile
,
PixelFormat
::
RGB_8
,
Intent
::
Saturation
,
Flags
::
NO_CACHE
)
.unwrap
();
let
out
=
[
0u8
;
3
];
sync
.transform_pixels
(
&
[[
1u8
,
2
,
3
]],
&
mut
[
out
]);
let
_
:
Box
<
dyn
Sync
>
=
Box
::
new
(
sync
);
let
tr
:
Box
<
dyn
std
::
fmt
::
Debug
+
Sync
>
=
Box
::
new
(
sync
);
eprintln!
(
"{:#?}"
,
tr
);
}
This diff is collapsed.
Click to expand it.
src/context.rs
+
14
−
1
View file @
2a83b000
use
std
::
rc
::
Rc
;
use
std
::
sync
::
Arc
;
use
super
::
*
;
use
std
::
fmt
;
use
std
::
ptr
;
use
std
::
mem
;
use
std
::
ffi
::
CStr
;
...
...
@@ -212,7 +213,7 @@ impl Drop for ThreadContext {
impl
Default
for
GlobalContext
{
fn
default
()
->
Self
{
Self
::
new
()
}
}
}
impl
Default
for
ThreadContext
{
...
...
@@ -221,6 +222,18 @@ impl Default for ThreadContext {
}
}
impl
fmt
::
Debug
for
ThreadContext
{
fn
fmt
(
&
self
,
f
:
&
mut
fmt
::
Formatter
)
->
fmt
::
Result
{
f
.write_str
(
"ThreadContext"
)
}
}
impl
fmt
::
Debug
for
GlobalContext
{
fn
fmt
(
&
self
,
f
:
&
mut
fmt
::
Formatter
)
->
fmt
::
Result
{
f
.write_str
(
"GlobalContext"
)
}
}
#[test]
fn
context
()
{
let
mut
c
=
ThreadContext
::
new
();
...
...
This diff is collapsed.
Click to expand it.
src/profile.rs
+
14
−
0
View file @
2a83b000
use
super
::
*
;
use
crate
::
context
::
Context
;
use
std
::
fmt
;
use
std
::
path
::
Path
;
use
std
::
ptr
;
use
std
::
io
;
...
...
@@ -580,6 +581,18 @@ fn tags_write() {
});
}
impl
fmt
::
Debug
for
Profile
{
fn
fmt
(
&
self
,
f
:
&
mut
fmt
::
Formatter
)
->
fmt
::
Result
{
let
mut
s
=
f
.debug_struct
(
"Profile"
);
let
l
=
Locale
::
none
();
s
.field
(
"Description"
,
&
self
.info
(
InfoType
::
Description
,
l
));
s
.field
(
"Manufacturer"
,
&
self
.info
(
InfoType
::
Manufacturer
,
l
));
s
.field
(
"Model"
,
&
self
.info
(
InfoType
::
Model
,
l
));
s
.field
(
"Copyright"
,
&
self
.info
(
InfoType
::
Copyright
,
l
));
s
.finish
()
}
}
#[test]
fn
setters
()
{
let
mut
p
=
Profile
::
new_placeholder
();
...
...
@@ -592,6 +605,7 @@ fn setters() {
fn
icc
()
{
let
prof
=
Profile
::
new_xyz
();
assert!
(
prof
.icc
()
.unwrap
()
.len
()
>
300
);
assert!
(
format!
(
"{:?}"
,
prof
)
.contains
(
"XYZ identity"
));
}
#[test]
...
...
This diff is collapsed.
Click to expand it.
src/transform.rs
+
29
−
11
View file @
2a83b000
...
...
@@ -2,6 +2,7 @@ use super::*;
use
crate
::
context
::
Context
;
use
std
::
os
::
raw
::
c_void
;
use
std
::
marker
::
PhantomData
;
use
std
::
fmt
;
/// Conversion between two ICC profiles.
///
...
...
@@ -173,16 +174,6 @@ impl<InputPixelFormat: Copy + Clone, OutputPixelFormat: Copy + Clone, Ctx: Conte
}
}
#[inline]
pub
fn
input_format
(
&
self
)
->
PixelFormat
{
unsafe
{
ffi
::
cmsGetTransformInputFormat
(
self
.handle
)
as
PixelFormat
}
}
#[inline]
pub
fn
output_format
(
&
self
)
->
PixelFormat
{
unsafe
{
ffi
::
cmsGetTransformOutputFormat
(
self
.handle
)
as
PixelFormat
}
}
#[inline]
pub
fn
new_flags_context
(
context
:
impl
AsRef
<
Ctx
>
,
input
:
&
Profile
<
Ctx
>
,
in_format
:
PixelFormat
,
output
:
&
Profile
<
Ctx
>
,
out_format
:
PixelFormat
,
...
...
@@ -225,7 +216,19 @@ impl<InputPixelFormat: Copy + Clone, OutputPixelFormat: Copy + Clone, Ctx: Conte
}
}
impl
<
InputPixelFormat
:
Copy
+
Clone
,
OutputPixelFormat
:
Copy
+
Clone
,
C
>
Transform
<
InputPixelFormat
,
OutputPixelFormat
,
GlobalContext
,
C
>
{
impl
<
F
,
T
,
C
,
L
>
Transform
<
F
,
T
,
C
,
L
>
{
#[inline]
pub
fn
input_format
(
&
self
)
->
PixelFormat
{
unsafe
{
ffi
::
cmsGetTransformInputFormat
(
self
.handle
)
as
PixelFormat
}
}
#[inline]
pub
fn
output_format
(
&
self
)
->
PixelFormat
{
unsafe
{
ffi
::
cmsGetTransformOutputFormat
(
self
.handle
)
as
PixelFormat
}
}
}
impl
<
F
,
T
,
L
>
Transform
<
F
,
T
,
GlobalContext
,
L
>
{
/// Adaptation state for absolute colorimetric intent, on all but cmsCreateExtendedTransform.
///
/// See `ThreadContext::adaptation_state()`
...
...
@@ -276,3 +279,18 @@ impl<F, T, C, L> Drop for Transform<F, T, C, L> {
}
}
impl
<
F
,
T
,
C
,
L
>
fmt
::
Debug
for
Transform
<
F
,
T
,
C
,
L
>
{
fn
fmt
(
&
self
,
f
:
&
mut
fmt
::
Formatter
)
->
fmt
::
Result
{
let
mut
s
=
f
.debug_struct
(
&
format!
(
"Transform<{}, {}, {}, {}>"
,
std
::
any
::
type_name
::
<
F
>
(),
std
::
any
::
type_name
::
<
T
>
(),
std
::
any
::
type_name
::
<
C
>
(),
std
::
any
::
type_name
::
<
L
>
(),
));
s
.field
(
"input_format"
,
&
self
.input_format
());
s
.field
(
"output_format"
,
&
self
.output_format
());
s
.finish
()
}
}
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