Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. I never fail to be impressed by this

I never fail to be impressed by this

Scheduled Pinned Locked Moved C / C++ / MFC
c++hardwarequestion
1 Posts 1 Posters 8 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    honey the codewitch
    wrote on last edited by
    #1

    Disclaimer: The following is intended to run in embedded environments that may not have a compliant STL if they have the STL at all. Some of this code could be replaced on systems with The STL to use std:: functionality. Anyway, it's code I wrote, but it's not my code that really impresses me about this, but rather the C++ compiler.

    static_assert(pixel_type::template equals>::value,
    "this code needs to be ported for your display format");

    That's a compile time check to determine if a pixel format is exactly the same as the specified pixel format. Not impressed yet? Those pixel formats are arbitrarily defined:

    // creates an RGB pixel by making each channel
    // one third of the whole. Any remainder bits
    // are added to the green channel
    template
    using rgb_pixel = pixel<
    channel_traits,
    channel_traits,
    channel_traits

    ;
    // creates an RGBA pixel by making each channel
    // one quarter of the whole. Any remainder bits
    // are added to the green channel
    template
    using rgba_pixel = pixel<
    channel_traits,
    channel_traits,
    channel_traits,
    channel_traits
    ;
    // creates a grayscale or monochome pixel
    template
    using gsc_pixel = pixel<
    channel_traits
    ;
    // creates a Y'UV pixel by making each channel
    // one third of the whole. Any remainder bits
    // are added to the Y' channel
    template
    using yuv_pixel = pixel<
    channel_traits,
    channel_traits,
    channel_traits
    ;

    And furthermore

    // defines a channel for a pixel
    template<
    // the channel name, like channel_name::R
    typename Name,
    // the bit depth
    size_t BitDepth,
    // the minimum value
    bits::uintx Min=0,
    // the maximum value
    #if HTCW_MAX_WORD >= 64
    bits::uintx Max= ((BitDepth==64)?0xFFFFFFFFFFFFFFFF:((1< Max= ((BitDepth==32)?0xFFFFFFFF:((1<

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups