/// <summary> /// Initializes a new <see cref="ColorBarGraphic"/> with the specified physical dimensions and orientation. /// </summary> /// <param name="size">The desired physical size of the colour bar.</param> /// <param name="orientation">A value specifying the desired orientation of the colour bar.</param> public ColorBarGraphic(Size size, ColorBarOrientation orientation) { _size = size; _location = new PointF(0, 0); _orientation = orientation; _reversed = false; _gradientPixelData = null; _colorMapManagerProxy = new ColorMapManager(new ColorMapInstallerProxy()); }
public BitmapSource ToBitmapSource(ColorBarOrientation colorBarOrientation) { // Define parameters used to create the BitmapSource. int width, height; if (colorBarOrientation == ColorBarOrientation.Vertical) { width = 1; height = colorMapLength; } else { width = colorMapLength; height = 1; } PixelFormat pf = PixelFormats.Bgr32; int bytes = (pf.BitsPerPixel + 7) / 8; int rawStride = (width * bytes); byte[] rawImage = new byte[rawStride * height]; byte[,] cmap = ToByteArray(); int index = 0; for (int c = colorMapLength - 1; c > 0; --c) { rawImage[index] = cmap[c, 3]; rawImage[index + 1] = cmap[c, 2]; rawImage[index + 2] = cmap[c, 1]; rawImage[index + 3] = cmap[c, 0]; index += bytes; } // Create a BitmapSource. BitmapSource bitmap = BitmapSource.Create(width, height, 96, 96, pf, null, rawImage, rawStride); return(bitmap); }
/// <summary> /// Initializes a new <see cref="ColorBarGraphic"/> with the specified logical dimensions and orientation. /// </summary> /// <param name="length">The desired logical length of the colour bar along which the spectrum of colours will be ordered.</param> /// <param name="width">The desired logical width of the colour bar.</param> /// <param name="orientation">A value specifying the desired orientation of the colour bar.</param> public ColorBarGraphic(int length, int width, ColorBarOrientation orientation) : this(orientation == ColorBarOrientation.Horizontal ? new Size(length, width) : new Size(width, length), orientation) {}
/// <summary> /// Initializes a new <see cref="ColorBarGraphic"/> in the specified orientation. /// </summary> /// <param name="orientation">A value specifying the desired orientation of the colour bar.</param> public ColorBarGraphic(ColorBarOrientation orientation) : this(125, 15, orientation) {}
public BitmapSource ToBitmapSource(ColorBarOrientation colorBarOrientation) { // Define parameters used to create the BitmapSource. int width, height; if (colorBarOrientation == ColorBarOrientation.Vertical) { width = 1; height = colorMapLength; } else { width = colorMapLength; height = 1; } PixelFormat pf = PixelFormats.Bgr32; int bytes = (pf.BitsPerPixel + 7) / 8; int rawStride = (width * bytes); byte[] rawImage = new byte[rawStride * height]; byte[,] cmap = ToByteArray(); int index = 0; for (int c = colorMapLength - 1; c > 0; --c) { rawImage[index] = cmap[c, 3]; rawImage[index + 1] = cmap[c, 2]; rawImage[index + 2] = cmap[c, 1]; rawImage[index + 3] = cmap[c, 0]; index += bytes; } // Create a BitmapSource. BitmapSource bitmap = BitmapSource.Create(width, height, 96, 96, pf, null, rawImage, rawStride); return bitmap; }
/// <summary> /// Initializes a new <see cref="ColorBarGraphic"/> with the specified logical dimensions and orientation. /// </summary> /// <param name="length">The desired logical length of the colour bar along which the spectrum of colours will be ordered.</param> /// <param name="width">The desired logical width of the colour bar.</param> /// <param name="orientation">A value specifying the desired orientation of the colour bar.</param> public ColorBarGraphic(int length, int width, ColorBarOrientation orientation) : this(orientation == ColorBarOrientation.Horizontal ? new Size(length, width) : new Size(width, length), orientation) { }
/// <summary> /// Initializes a new <see cref="ColorBarGraphic"/> in the specified orientation. /// </summary> /// <param name="orientation">A value specifying the desired orientation of the colour bar.</param> public ColorBarGraphic(ColorBarOrientation orientation) : this(125, 15, orientation) { }