Biicode-logo
  • Explore
  • Plans
  • Learn
    • Get Started
    • Downloads
    • Docs
    • Blog
    • Forum
  • Log in
C/C++ Arduino Raspberry Pi (cross compiling) Node.js
  • Biicode
    • Installation
      • Install Biicode
      • Install C/C++ tools
      • Debian based distributions
      • Arch based distributions
      • Run biicode from source
      • Install C/C++ tools manually
        • Verify your installation
      • Connect through a proxy server
    • Getting started
      • Basics
      • Create your first project
        • [optional] Keeping #includes short
      • Using an IDE
      • Build and run
      • Publishing
    • Dependencies
      • Dependencies
      • Modifying the version you depend on
        • Depending on a block track
    • Publishing
      • Tag a version
      • Private blocks
    • Custom build configuration
      • CMake basics
      • Where is biicode´s “magic”?
      • Define and prepare targets
        • Which source code files are part of the block’s library
        • Choose STATIC or SHARED library
        • Modify which executable targets are made
        • Which source code files are part of each executable
        • Modify which test targets are made
      • Configure targets
        • Configure library target
        • Configure executable target
      • Select build type: Debug or Release
      • Complete variable reference
    • Adapt your library
      • Concepts to understand
        • Key facts
      • Without a previous CMakeLists.txt
        • 1. Look for unresolved dependencies with bii deps
        • 2. Execute bii build
        • 3. Test the libary’s reusability
      • With a previous CMakeLists.txt
        • Option 1: Let biicode do its job in an isolated file
        • Option 2: Build your own target library and link them to BII_LIB_TARGET
        • Option 3: Adapt your CMakeLists.txt filtering files
    • Advanced Usage
      • Custom Layouts
        • Simple Layout
        • TMP Layout
        • Classic Layout
        • CLion Layout
      • Tests
      • Open multiple blocks
        • Working with your own blocks
        • Opening your block
        • Publishing updated code
        • Closing edited block
        • Working with any published block
        • Open a block
        • Publish the changes
        • Close the block
        • Depend on the block you’ve just published
      • Toolchains
      • Override a dependency
        • Override a dependency with block tracks
      • Advanced build configuration
        • Publish, share and reuse CMake scripts
        • Overriding dependencies build options and configuration
      • Publish a block track
        • Publish a new block Track
      • Private blocks
    • Examples
      • Basic Compression Library
        • Simple Huffman Compression - Uncompression
        • Open and build
      • Boost Libraries
        • Boost.Lambda
        • Boost.Coroutine
        • Alternative setup call
        • Extra configuration variables
        • Contribute to the setup scripts
      • Box2D
        • Bounces of a circle falling
        • Open and build
      • C++ challenge
        • Create a new project
        • Copy the code
        • Find and retrieve dependencies
        • Build and run
      • CImg
        • Tron game
        • Open and build
      • Crypto++
        • Encrypt a message
        • Open and build
      • CSparse
        • Read a matrix and solve a linear system
        • Create a new project
        • Open and build
      • cURL
        • HTML page gatherer
        • Open and build
      • Eigen
        • Middle rows from a matrix
        • Open and build
      • Expression Parser
        • Simple form of mathematical expression parsing
        • Open and build
      • fit
        • Tests
      • Flatbuffers
        • Charge a *.fbs file and generate a C++ header
      • Freeglut
        • 1. Create a new project
        • 2. Creating reusable code
        • 3. Find dependencies
        • 4. Build and run
      • GLFW
        • Running the examples
      • GLUI User Interface Library
        • GLUI Window Template
      • Google Mock (GMock)
        • GMock Examples
        • Mocking a simple function
      • Google Test (GTest)
        • Testing a factorial function: Simple test
        • Testing a factorial function: Test suites
        • Open and build
      • HTTP Server
        • How does it work?
        • How can I use it?
        • The code
        • Supported Operating Systems
        • More information
        • List of dependencies
      • json11
        • Simple convert data to json and vice versa
      • json++
        • Simple parser and converter from JSON to XML
      • Miniutf
      • Multivariate Splines
      • libuv
        • Http client/server application
        • Change libuv’s version
      • Little CMS
        • ICC Profile Examples
        • Open and build
      • Log4z
        • Fast stream log strings test
      • lwan Web Server
        • Hello World Example
      • MiLi
      • MuParser
      • OpenCV
        • Showing an image and detecting faces
        • Open and build
      • OpenSSL
        • Encrypting with MD5 and SHA1
        • Develop your project
        • Open and build
      • POCO
        • PDF example
        • Using NetSSL_OpenSSL or NetSSL_Win library
      • PTypes
      • SDL
        • Graphical window interface
        • Open and build
      • SQLite
        • Shopping list database
        • SQLite++ Wrapper
        • Open and build
      • TinyThread++
        • Open and build the examples
        • Simple Hello World with a thread
        • Draw a fractal
      • Zlib
        • Usage example (difficulty: medium)
      • ZMQ
        • Simple client-server with C++ binding
      • ZMQ with Google Protocol Buffers Serialization
    • Integrations
      • Generators and IDEs
        • Eclipse CDT
        • Visual Studio
        • CLion
      • IDEs and VCS
      • Git (GitHub, Bitbucket, etc.)
        • With a new repository
        • Create a block from a git repository
        • Publish from git commit
      • Continuous Integration
        • AppVeyor
        • Travis CI
      • Koding
      • Doxygen
        • Create a Doxyfile template
        • Edit your Doxyfile
        • Generate the Documentation
    • Reference
      • biicode.conf: configure your biicode projects
        • [requirements]
        • [parent]
        • [paths]
        • [dependencies]
        • [mains]
        • [tests]
        • [hooks]
        • [includes]
        • [data]
      • Commands
        • bii build: build your project
        • bii buzz: init, find and build
        • bii clean: delete meta-information
        • bii close: finish editing published blocks
        • bii configure: configure your project
        • bii deps: show block dependencies
        • bii diff: compare block versions
        • bii find: find your external dependencies
        • bii init: creates a new project
        • bii new: creates new blocks
        • bii open: edit published blocks
        • bii publish: publish your blocks
        • bii setup: install necessary tools
        • bii test: test your code
        • bii update: update a block
        • bii user: specify your username
      • Configuration Files
        • layout.bii: define your project layout
        • policies.bii: defining the policies for the code you want to reuse
        • ignore.bii: filtering your files
        • settings.bii: defining your tools and preferences
        • types.bii: configuring non-standard file extensions
    • Release notes
    • FAQs
      • Is biicode free?
      • Is biicode an editor in the cloud?
      • Is biicode a VCS?
      • Can I use biicode with my favourite VCS?
      • Which languages are supported?
      • How does biicode relate to Maven, NPM, PyPI...?
    • Troubleshooting
      • Eclipse projects: “Launch failed. Binary not found” (OS X)
      • g++ doesn’t compile simple code, using thread header
      • Default Build Configuration with bii build not working
  • Arduino
    • Installation
      • Install Biicode
      • Install Arduino tools
      • Install Arduino tools manually
        • Install Arduino SDK manually
    • Getting started
      • Installing biicode and Arduino tools
      • Create your project
      • Define your board
      • Build and upload your program
      • Depending on Fenix Blink
      • Build and upload
    • Arduino commands
      • bii configure -t arduino: configure your project
      • bii build: build your project
      • bii arduino:upload: send your code into the Arduino
      • bii arduino:settings: configure your Arduino settings
      • bii arduino:monitor: start a serial monitor
      • bii configure –toolchain=arduino: enable, disable or change the Arduino cross compilation
    • How to
      • Eclipse IDE configuration
        • How to import your project
        • How to fix “Unresolved inclusion: Arduino.h”
      • Configure your SDK, port and board
        • I changed my Arduino’s port, what happens now?
        • How can I change my Arduino project properties?
        • bii arduino:settings options
      • How to adapt your code
        • 1. Projects with one single .ino file
        • 2. Projects with multiple .ino files
      • How to use the Arduino Yun
        • Download Arduino 1.5
        • Configure your settings
    • Examples
      • Arduino Serial Monitor
        • C++ code
        • Turn ON/OFF one LED
      • Servo and LCD 2x16
        • What do we need?
        • Scheme
        • The code: Display the servo angle into a LCD
        • Build and upload the code
      • Arduino Serial Interface
        • How does it work?
        • How do I use it?
        • C++ code
        • Arduino code
        • Build and run!
    • Troubleshooting
      • Launching Arduino IDE, I get an error ./arduino: 22: ./arduino: java: not found in Ubuntu
  • Raspberry Pi Cross Compilation
    • Installation
      • Install Biicode
      • Install RPI tools
      • Install RPI cross-compiling tools manually
        • C++ tools installation
        • Raspberry Pi tools installation
    • Getting started
      • 1. Installing biicode and C/C++ cross-building tools
      • 2. Create your project
      • 3. Build and run your program (cross-compiling)
      • 4. Send your executable to your Raspberry Pi
      • 5. Depending on WiringPi
    • RPi commands
      • bii rpi:send: send a bin folder
      • bii rpi:settings: configure your Raspberry Pi settings
      • bii rpi:ssh: connect by ssh with the Raspberry Pi
      • bii configure –toolchain=rpi: enable, disable or change the Raspberry Pi cross compilation.
    • How to
      • Installing the biicode package from downloads page is too slow
      • Output selection and volume control
      • Raspberry Pi GPIO Pin Layout
    • Examples
      • WiringPi: C GPIO library
        • How to make a LED blink with Raspberry Pi
        • How to use the RPi PWM output to control a motor
        • How to use softServo to control a Servo
      • HTTP Server: how to control a led by web
        • How can i use it?
      • A funny moving doll with Raspberry PI and biicode
        • You just need paper, scissors, a servo, a Raspberry Pi and biicode!
        • Choose the paper doll you like most
        • Putting it all together!
        • Stick the head to the servo and put the servo in the body
        • Connect the servo to the 5v, GPIO17 and 0v pins
    • Troubleshooting
      • Is it possible to change the version of gcc used for cross-compiling to the Raspberry Pi?
  • Node.js
    • Getting started
      • 1. Installing biicode and node.js
      • 2. Create your project
      • 3. Run your program
      • 4. Depending on redis
    • How to
      • Run your node programs
Read the Docs v: latest
Versions
latest
stable
Downloads
pdf
htmlzip
epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.
  • biicode docs
  • Biicode
  • Examples
  • Little CMS
  • Edit on GitHub
libuv
Log4z

Little CMS¶

Little CMS is an Open Source Color Management Engine. This example demonstrates how to get started using LittleCMS by Marti Maria with biicode.

Little CMS intends to be an OPEN SOURCE small-footprint color management engine, with special focus on accuracy and performance. It uses the International Color Consortium standard (ICC), which is the modern standard when regarding to color management. This examples have been tested in Windows, OS X and Linux-systems. Check the Sources:

  1. Original Little CMS Library.
  2. Biicode Little CMS block at martimaria/littlecms.
  3. Github repository.
  4. LittleCMS Documentation.

ICC Profile Examples¶

In this example we’ll create a devicelink that decodes TIFF8 Lab files using Little CMS. You only have to write #include "lcms2.h" at the top of your code.

Creating a new project¶

Create a new project and a lcms-main.c file:

$ bii init lcms -L
$ cd lcms
$ # Create lcms-main.c and copy the code

lcms-main.c

//  Little cms
//  Copyright (C) 1998-2010 Marti Maria
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the Software
// is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

// Creates a devicelink that decodes TIFF8 Lab files

#include "lcms2.h"
#include <stdlib.h>
#include <math.h>

static
double DecodeAbTIFF(double ab)
{
  if (ab <= 128.)
    ab += 127.;
  else
    ab -= 127.;

  return ab;
}

static
cmsToneCurve* CreateStep(void)
{
  cmsToneCurve* Gamma;
  cmsUInt16Number* Table;
  int i;
  double a;

  Table = calloc(4096, sizeof(cmsUInt16Number));
  if (Table == NULL) return NULL;

  for (i=0; i < 4096; i++) {
    a = (double) i * 255. / 4095.;
    a = DecodeAbTIFF(a);
    Table[i] = (cmsUInt16Number) floor(a * 257. + 0.5);
  }
  Gamma = cmsBuildTabulatedToneCurve16(0, 4096, Table);
  free(Table);
  return Gamma;
}


static
cmsToneCurve* CreateLinear(void)
{
  cmsUInt16Number Linear[2] = { 0, 0xffff };
  return cmsBuildTabulatedToneCurve16(0, 2, Linear);
}



// Set the copyright and description
static
cmsBool SetTextTags(cmsHPROFILE hProfile)
{
    cmsMLU *DescriptionMLU, *CopyrightMLU;
    cmsBool  rc = FALSE;
    DescriptionMLU  = cmsMLUalloc(0, 1);
    CopyrightMLU    = cmsMLUalloc(0, 1);
    if (DescriptionMLU == NULL || CopyrightMLU == NULL) goto Error;
    if (!cmsMLUsetASCII(DescriptionMLU,  "en", "US", "Little cms Tiff8 CIELab")) goto Error;
    if (!cmsMLUsetASCII(CopyrightMLU,    "en", "US", "Copyright (c) Marti Maria, 2010. All rights reserved.")) goto Error;
    if (!cmsWriteTag(hProfile, cmsSigProfileDescriptionTag,  DescriptionMLU)) goto Error;
    if (!cmsWriteTag(hProfile, cmsSigCopyrightTag,           CopyrightMLU)) goto Error;
    rc = TRUE;

Error:
    if (DescriptionMLU)
        cmsMLUfree(DescriptionMLU);
    if (CopyrightMLU)
        cmsMLUfree(CopyrightMLU);
    return rc;
}


int main(int argc, char *argv[])
{
  cmsHPROFILE hProfile;
  cmsPipeline *AToB0;
  cmsToneCurve* PreLinear[3];
  cmsToneCurve *Lin, *Step;

  fprintf(stderr, "Creating lcmstiff8.icm...");

    remove("lcmstiff8.icm");
  hProfile = cmsOpenProfileFromFile("lcmstiff8.icm", "w");

  // Create linearization
  Lin  = CreateLinear();
  Step = CreateStep();

  PreLinear[0] = Lin;
  PreLinear[1] = Step;
  PreLinear[2] = Step;

  AToB0 = cmsPipelineAlloc(0, 3, 3);
  cmsPipelineInsertStage(AToB0,
  cmsAT_BEGIN, cmsStageAllocToneCurves(0, 3, PreLinear));
  cmsSetColorSpace(hProfile, cmsSigLabData);
  cmsSetPCS(hProfile, cmsSigLabData);
  cmsSetDeviceClass(hProfile, cmsSigLinkClass);
  cmsSetProfileVersion(hProfile, 4.2);
  cmsWriteTag(hProfile, cmsSigAToB0Tag, AToB0);
  SetTextTags(hProfile);
  cmsCloseProfile(hProfile);
  cmsFreeToneCurve(Lin);
  cmsFreeToneCurve(Step);
  cmsPipelineFree(AToB0);

  fprintf(stderr, "Done.\n");
  return 0;
}

Manage your dependencies¶

Check the dependencies of the project with bii deps:

INFO: Processing changes...
youruser/lcms depends on:
      system:
         math.h
         stdlib.h
      unresolved:
         lcms2.h

Now, edit the biicode.conf file generated in the project folder. Map your [includes] to point to martimatia/littlecms:

[includes]
    lcms2.h: martimaria/littlecms/include/

Now do bii find and biicode will find the most recent version available of Little CMS library:

$  bii find
INFO: Processing changes...
INFO: Finding missing dependencies in server
INFO: Looking for martimaria/littlecms...
INFO: Block candidate: martimaria/martimaria/littlecms/master
INFO:   Version martimaria/littlecms: 1 (STABLE) valid
INFO:   Version martimaria/littlecms: 0 (STABLE) valid
INFO: Analyzing compatibility for found dependencies...
INFO: All dependencies resolved
Find resolved new dependencies:
        martimaria/littlecms: 1
INFO: Saving files from: martimaria/littlecms

Have a look at your biicode.conf again to ensure Little CMS library was added to your project:

[requirements]
    martimaria/littlecms: 1

[includes]
    lcms2.h: martimaria/littlecms/include/

Check again with bii deps and now all dependencies are resolved.

Build the project¶

Next, the only thing left is building the project:

$ bii build

Execute the binary placed in bin directory:

$ bin/youruser_lcms_lcms-main

Once you execute you should see an output like this one, and a the lcmstiff8.icm file created into your bin folder:

Creating lcmstiff8.icm...Done

You can find more examples at examples/littlecms, give them a try!

Open and build¶

This example is already in biicode at examples/littlecms.

It is simple to run, just open the block and build it like this:

$ bii init lcms
$ cd lcms
$ bii open examples/littlecms

There are three different files in the project, note that all of them use Little CMS , simply by including the library.

Build the block and execute any of them!

$ bii build
$ cd bin
$ # Execute!

Any doubts? Do not hesitate to contact us visit our forum and feel free to ask any questions.

libuv
Log4z

© Copyright 2014, biicode.