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
3890dc9f
Commit
3890dc9f
authored
7 years ago
by
Kornel
Browse files
Options
Downloads
Patches
Plain Diff
Documentation
parent
4a2d44af
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/lib.rs
+3
-0
3 additions, 0 deletions
src/lib.rs
src/transform.rs
+26
-6
26 additions, 6 deletions
src/transform.rs
with
29 additions
and
6 deletions
src/lib.rs
+
3
−
0
View file @
3890dc9f
//! See [Little CMS full documentation](https://pornel.github.io/rust-lcms2-sys/) for more in-depth information about LCMS functions.
//!
//! The main types you need to use in this crate are `Profile` and `Transform`
#![allow(dead_code)]
extern
crate
lcms2_sys
as
ffi
;
#[macro_use]
extern
crate
foreign_types
;
...
...
This diff is collapsed.
Click to expand it.
src/transform.rs
+
26
−
6
View file @
3890dc9f
...
...
@@ -3,11 +3,27 @@ use context::Context;
use
std
::
os
::
raw
::
c_void
;
use
std
::
marker
::
PhantomData
;
/// Conversion between two ICC profiles
/// Conversion between two ICC profiles
.
///
/// Usually you don't need to specify `InputPixelFormat`/`OutputPixelFormat` parameters explicitly.
/// They will be inferred from the call to `transform_pixels` or `transform_in_place`.
/// You might get "cannot infer type for `InputPixelFormat`" error before you write calls to one of these functions.
/// The transform ensures type safety and thread safety at compile time. To do this, it has a few generic types associated with it.
/// Usually, you don't need to specify any of the generic parameters (like `InputPixelFormat`/`OutputPixelFormat`) explicitly,
/// because they are inferred from calls to constructors and `transform_pixels` or `transform_in_place`.
///
/// If you get error such as:
///
/// > cannot infer type for `InputPixelFormat`
/// > type annotations required: cannot resolve `_: std::marker::Copy`
///
/// then don't worry! Write some code that calls `transform_pixels()`,
/// because this is the function that makes the type of the transform clear.
///
/// * `InputPixelFormat` — e.g. `(u8,u8,u8)` or struct `RGB<u8>`, etc.
/// The type must have appropriate number of bytes per pixel (i.e. you can't just use `[u8]` for everything).
/// * `OutputPixelFormat` — similar to `InputPixelFormat`. If both are the same, then `transform_in_place()` function works.
/// * `Context` — it's `GlobalContext` for the default non-thread-safe version, or `ThreadContext` for thread-safe version.
/// Thread-safety:
///
/// * Transform is `Send` if you create it with `ThreadContext` (use `new_*_context()` functions).
pub
struct
Transform
<
InputPixelFormat
,
OutputPixelFormat
,
Context
=
GlobalContext
>
{
pub
(
crate
)
handle
:
ffi
::
HTRANSFORM
,
_from
:
PhantomData
<
InputPixelFormat
>
,
...
...
@@ -20,11 +36,15 @@ unsafe impl<'a, F, T, C: Send> Send for Transform<F, T, C> {}
impl
<
InputPixelFormat
:
Copy
+
Clone
,
OutputPixelFormat
:
Copy
+
Clone
>
Transform
<
InputPixelFormat
,
OutputPixelFormat
,
GlobalContext
>
{
/// Creates a color transform for translating bitmaps.
///
/// Basic, non-tread-safe version.
///
/// * Input: Handle to a profile object capable to work in input direction
/// * InputFormat: A bit-field format specifier
as described in Formatters section.
/// * InputFormat: A bit-field format specifier
/// * Output: Handle to a profile object capable to work in output direction
/// * OutputFormat: A bit-field format specifier
as described in Formatters section.
/// * OutputFormat: A bit-field format specifier
/// * Intent: Rendering intent
///
/// See documentation of these types for more detail.
pub
fn
new
(
input
:
&
Profile
,
in_format
:
PixelFormat
,
output
:
&
Profile
,
...
...
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