PictureEffectsRaw Xojo Plugin

GrayscaleEffectRaw Class (console safe)

A class to change picture contained in RawBitmap from color to grayscale picture.

Supports:
  • 8 bit per channel bitmaps

  • 16 bit per channel bitmaps

  • RGB color spaces

  • Synchronous and asynchronous modes supported



  • This class supports use of multiple CPU cores.

    MPImageFilterRaw
       GrayscaleEffectRaw

    class GrayscaleEffectRaw implements

    IRawBitmapProcessor

    IRawBitmapProcessorAsync

    Properties

    GrayscaleType (console safe) Use this property to specify which GrayScale algorithm to use.
    Mask (console safe) Sets mask for the operation if masking is wanted.
    UseOriginalColorSpace (console safe) If set to true then the result will have same color space as the RawBitmap passed in.
    AsyncCompleted (Inherited) (console safe) Returns true if asynchronous execution has completed, else false.
    AsyncResult (Inherited) (console safe) Returns the result bitmap of asynchronous execution.
    Canceled (Inherited) (console safe) If this one returns true then the effects execution was canceled by a Progress handler.
    CPUCoreCount (Inherited) (console safe) Returns number of detected CPU cores on the running machine.
    ErrorCode (Inherited) (console safe) Returns error code after applying the effect. This value is a Constant defined in the PictureEffectsRawError module.
    MultiprocessingHint (Inherited) (console safe) Use this property to fine tune CPU usage for this algorithm. By default this property is set to zero (Automatic). This property accepts all constants that are defined in this class.
    ProgressHandler (Inherited) (console safe) Use this property to use a progress class to get progress feedback from this function. This class must be a class that Implements the IProgressHandler Interface which is defined in this plugin.

    Methods

    Apply (console safe) Applies the effect on a RawBitmap image with parameters that have been set on the class instance.
    Apply (console safe) Applies the effect on a RawBitmap image with parameters that have been set on the class instance, taking additionally grayscaleMethod as parameter.
    ApplyAsync (console safe) Applies the effect asynchronously on a RawBitmap image with parameters that have been set on the class instance.
    ApplyInPlace (console safe) Applies the effect on a RawBitmap image with parameters that have been set on the class instance, and the RawBitmap passed in will also get the result image.
    ApplyInPlaceAsync (console safe) Applies the effect asynchronously on a RawBitmap image with parameters that have been set on the class instance, and the RawBitmap passed in will also get the result image.
    Cancel (Inherited) (console safe) Cancels processing and waits for threads to come to full stop when in asynchronous execution.

    Constants

    NTSC_PAL = 0 NTSC/PAL
    ITU_R = 1 ITU_R
    AVERAGE = 2 Average
    WEIGHTEDAVERAGE = 3 Weighted average
    CPU_USE_MACHINE_CORE_COUNT = -1 (Inherited) Uses exactly the number of available CPU cores in the machine. (Available here means on-line CPU cores, some laptops can put CPU cores off line in low battery situations)
    CPU_USE_AUTOMATIC = 0 (Inherited) Takes into account number of available CPU cores on the Machine and also tries to select the fastest way based on developer rating for each algorithm and picture size. (In simple algorithms then the fastest path is sometimes 2 or 3 CPU cores and not 4 CPU cores because of the overhead of managing multiple cores). In more complex algorithms then 3 or 4 cores are almost always faster than 2 cores.
    CPU_USE_1_CORE = 1 (Inherited) Uses one CPU core.
    CPU_USE_2_CORES = 2 (Inherited) Uses two CPU cores. This setting will also work on machines with less than two CPU cores, but it will be slower or best case same speed as using the correct setting for such machine.
    CPU_USE_3_CORES = 3 (Inherited) Uses three CPU cores. This setting will also work on machines with less than three CPU cores, but it will be slower or best case same speed as using the correct setting for such machine.
    CPU_USE_4_CORES = 4 (Inherited) Uses four CPU cores. This setting will also work on machines with less than four CPU cores, but it will be slower or best case same speed as using the correct setting for such machine.
    CPU_USE_5_CORES = 5 (Inherited) Uses five CPU cores. This setting will also work on machines with less than five CPU cores, but it will be slower or best case same speed as using the correct setting for such machine.
    CPU_USE_6_CORES = 6 (Inherited) Uses six CPU cores. This setting will also work on machines with less than six CPU cores, but it will be slower or best case same speed as using the correct setting for such machine.
    CPU_USE_7_CORES = 7 (Inherited) Uses seven CPU cores. This setting will also work on machines with less than seven CPU cores, but it will be slower or best case same speed as using the correct setting for such machine.
    CPU_USE_8_CORES = 8 (Inherited) Uses eight CPU cores. This setting will also work on machines with less than eight CPU cores, but it will be slower or best case same speed as using the correct setting for such machine.

    Result from this class will always be RawBitmap with Gray or Gray and Alpha channel unless the UseOriginalColorSpace property was set to true or if Mask was used to only gray parts of the image. Alpha channel is always preserved and passed out also if there was one.

    Dim result as RawBitmap
    Dim effect as GrayscaleEffectRaw
    Dim p as Picture

    // The rawpic RawBitmap object could either be read directly from disk using GraphicsFormats plugin or converted from a Picture object using RawBitmapConverter.FromPicture

    effect = new GrayscaleEffectRaw()
    effect.Mask = new RawBitmapMask(40,40, rawpic.Width - 80, rawpic.Height-80) // A Rect mask does not create expensive bitmap mask under the hood
    effect.Mask.Inverted = true

    result = effect.Apply(rawpic,GrayscaleEffectRaw.NTSC_PAL)
    p = RawBitmapConverter.ToPicture(result)

    Supported Platforms:

  • MacOS X Carbon
  • MacOS X Cocoa 32 bit
  • MacOS X Cocoa 64 bit
  • Windows 32 bit
  • Windows 64 bit
  • Linux 32 bit
  • Linux 64 bit
  • Linux ARM