示例#1
0
        /// <summary>
        /// Метод, предназначенный для квантования изображения
        /// </summary>
        /// <param name="bitmap"></param>
        /// <param name="n"></param>
        /// <returns></returns>
        public static Bitmap Quantization(Bitmap bitmap, int n)
        {
            BufferedImage img = new BufferedImage(bitmap);
            Color         color;

            for (int i = 0; i < img.getWidth(); i++)
            {
                for (int j = 0; j < img.getHeight(); j++)
                {
                    color = new Color(img.getRGB(i, j));
                    if (color.getRed() % n != 0 && color.getRed() != 0)
                    {
                        img.setRGB(i, j, new Color(newColor(color.getRed(), n), color.getGreen(), color.getBlue()).getRGB());
                    }
                    if (color.getBlue() % n != 0 && color.getBlue() != 0)
                    {
                        img.setRGB(i, j, new Color(color.getRed(), color.getGreen(), newColor(color.getBlue(), n)).getRGB());
                    }
                    if (color.getGreen() % n != 0 && color.getGreen() != 0)
                    {
                        img.setRGB(i, j, new Color(color.getRed(), newColor(color.getGreen(), n), color.getBlue()).getRGB());
                    }
                }
            }
            return(img.getBitmap());
        }
示例#2
0
        /// <summary>
        /// Метод, предназначенный для вырезания части изображения и увеличения его в 4 раза
        /// </summary>
        /// <param name="bitmap"></param>
        /// <param name="x1"></param>
        /// <param name="y1"></param>
        /// <param name="x2"></param>
        /// <param name="y2"></param>
        /// <param name="n"></param>
        /// <returns></returns>
        public static Bitmap FragmentCut(Bitmap bitmap, int x1 = 160, int y1 = 160, int x2 = 240, int y2 = 240, int n = 4)
        {
            BufferedImage img    = new BufferedImage(bitmap);
            int           width  = x2 - x1;
            int           height = y2 - y1;
            BufferedImage newImg = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);

            for (int i = x1, ik = 0; i < x2; i++, ik++)
            {
                for (int j = y1, jk = 0; j < y2; j++, jk++)
                {
                    Color color = new Color(img.getRGB(i, j));
                    newImg.setRGB(ik, jk, color.getRGB());
                }
            }
            BufferedImage resizeNewImg = new BufferedImage(width * n, height * n, BufferedImage.TYPE_INT_RGB);

            for (int i = 0, i1 = 0; i < width; i++, i1 += 4)
            {
                for (int j = 0, j1 = 0; j < height; j++, j1 += 4)
                {
                    Color color = new Color(newImg.getRGB(i, j));
                    for (int k = 0; k < n; k++)
                    {
                        resizeNewImg.setRGB(i1 + k, j1 + k, color.getRGB());
                    }
                }
            }
            return(resizeNewImg.getBitmap());
        }
        public void fill(java.awt.Color color)
        {
            if (color == null)
            {
                String message = Logging.getMessage("nullValue.ColorIsNull");
                Logging.logger().severe(message);
                throw new ArgumentException(message);
            }

            java.awt.Graphics2D g2d = this.getGraphics();

            // Keep track of the previous color.
            java.awt.Color prevColor = g2d.getColor();
            try
            {
                // Fill the raster with the specified color.
                g2d.setColor(color);
                g2d.fillRect(0, 0, this.getWidth(), this.getHeight());
            }
            finally
            {
                // Restore the previous color.
                g2d.setColor(prevColor);
            }
        }
示例#4
0
 static private Color FromNativeColor(
     awt.Color awtColor, string name, KnownColor knownColor)
 {
     return(Color.FromArgbSystem(awtColor.getAlpha(),
                                 awtColor.getRed(), awtColor.getGreen(), awtColor.getBlue(),
                                 name, knownColor));
 }
 public virtual double calibrate(Color[] referenceColors, Color[] deviceColors)
 {
   if (!ColorCalibrator.\u0024assertionsDisabled && referenceColors.Length != deviceColors.Length)
   {
     Throwable.__\u003CsuppressFillInStackTrace\u003E();
     throw new AssertionError();
   }
   else
   {
     this.device.getRGBColorOrder();
     int num = referenceColors.Length * 3;
     throw new NoClassDefFoundError("com.googlecode.javacv.cpp.opencv_core$CvMat");
   }
 }
示例#6
0
        /// <summary>
        /// Изменение размера изображения
        /// </summary>
        /// <param name="bitmap"></param>
        /// <param name="n"></param>
        /// <returns></returns>
        public static Bitmap DecreaseImageResolution(Bitmap bitmap, int n)
        {
            BufferedImage img    = new BufferedImage(bitmap);
            BufferedImage newImg = new BufferedImage(bitmap.Width / n, bitmap.Height / n, BufferedImage.TYPE_INT_RGB);

            for (int i = 0, ik = 0; ik < img.getWidth(null); i++, ik += n)
            {
                for (int j = 0, jk = 0; jk < img.getHeight(null); j++, jk += n)
                {
                    Color color = new Color(img.getRGB(ik, jk));
                    newImg.setRGB(i, j, color.getRGB());
                }
            }
            return(newImg.getBitmap());
        }
示例#7
0
        /**
         * Creates a hexadecimal string representation of a {@link Color} in the form 0xaabbggrr.
         *
         * @param color Color to encode.
         *
         * @return String encoding of the specified color.
         *
         * @throws ArgumentException If the specified color is null.
         * @see #decodeColorABGR(String)
         * @see #encodeColorRGBA(java.awt.Color)
         */
        public static String encodeColorABGR(java.awt.Color color)
        {
            if (color == null)
            {
                String message = Logging.getMessage("nullValue.ColorIsNull");
                Logging.logger().severe(message);
                throw new ArgumentException(message);
            }

            // Encode the red, green, blue, and alpha components
            int rgba = (color.getRed() & 0xFF)
                       | (color.getGreen() & 0xFF) << 8
                       | (color.getBlue() & 0xFF) << 16
                       | (color.getAlpha() & 0xFF) << 24;

            return(String.Format("%#08X", rgba));
        }
示例#8
0
        /// <summary>
        /// Линейное контратирование изображения
        /// </summary>
        /// <param name="bitmap"></param>
        /// <returns></returns>
        public static Bitmap SetsContrans(Bitmap bitmap)
        {
            BufferedImage img = new BufferedImage(bitmap);
            Color         color;

            for (int i = 0; i < img.getWidth(); i++)
            {
                for (int j = 0; j < img.getHeight(); j++)
                {
                    color = new Color(img.getRGB(i, j));
                    int r = color.getRed();
                    int g = color.getGreen();
                    int b = color.getBlue();

                    if (r > 94)
                    {
                        r = 94;
                    }
                    else if (r < 28)
                    {
                        r = 28;
                    }
                    if (g > 94)
                    {
                        g = 94;
                    }
                    else if (g < 28)
                    {
                        g = 28;
                    }
                    if (b > 94)
                    {
                        b = 94;
                    }
                    else if (b < 28)
                    {
                        b = 28;
                    }

                    img.setRGB(i, j, new Color(r, g, b).getRGB());
                }
            }
            return(img.getBitmap());
        }
示例#9
0
        /// <summary>
        /// Метод, для пороговой обработки изображения
        /// </summary>
        /// <param name="bitmap">позволяет считывать и сохранять файлы различных графических форматов</param>
        /// <param name="rRed"></param>
        /// <param name="rGreen"></param>
        /// <param name="rBlue"></param>
        /// <returns></returns>
        public static Bitmap ThresholdProcessing(Bitmap bitmap, int rRed, int rGreen, int rBlue)
        {
            BufferedImage img = new BufferedImage(bitmap);

            for (int i = 0; i < img.getWidth(); i++)
            {
                for (int j = 0; j < img.getHeight(); j++)
                {
                    Color color = new Color(img.getRGB(i, j));
                    int   red   = color.getRed();
                    int   green = color.getGreen();
                    int   blue  = color.getBlue();

                    red   = red <= rRed ? red : 0;
                    green = green <= rGreen ? green : 0;
                    blue  = blue <= rBlue ? blue : 0;

                    img.setRGB(i, j, new Color(red, green, blue).getRGB());
                }
            }
            return(img.getBitmap());
        }
示例#10
0
 /// <summary>
 /// Sets the background color of this component.
 /// </summary>
 public void setBackground(Color @c)
 {
 }
示例#11
0
		/// <summary>
		/// Sets the background color for the <code>Graphics2D</code> context.
		/// </summary>
		abstract public void setBackground(Color @color);
		/// <summary>
		/// Sets the color to use for the background if node is selected.
		/// </summary>
		public void setBackgroundSelectionColor(Color @newColor)
		{
		}
示例#13
0
 public WPIColor(Color color)
 {
   WPIColor wpiColor = this;
   double num1 = (double) color.getRed();
   double num2 = (double) color.getGreen();
   double num3 = (double) color.getBlue();
   throw new NoClassDefFoundError("com.googlecode.javacv.cpp.opencv_core");
 }
示例#14
0
 internal WPIColor([In] object obj0, [In] Color obj1)
 {
   // ISSUE: type reference
   ByteCodeHelper.DynamicCast(obj0, __typeref (WPIColor), "com.googlecode.javacv.cpp.opencv_core$CvScalar");
   // ISSUE: explicit constructor call
   this.\u002Ector(obj0);
   WPIColor wpiColor = this;
   this.color = obj1;
 }
示例#15
0
		/// <summary>
		/// Draws as much of the specified image as is currently available.
		/// </summary>
		abstract public bool drawImage(Image @img, int @x, int @y, Color @bgcolor, ImageObserver @observer);
示例#16
0
		/// <summary>
		/// Sets this graphics context's current color to the specified
		/// color.
		/// </summary>
		abstract public void setColor(Color @c);
		/// <summary>
		/// Sets the color to use for the border.
		/// </summary>
		public void setBorderSelectionColor(Color @newColor)
		{
		}
		/// <summary>
		/// Sets the current color used to render the selected text.
		/// </summary>
		public void setSelectedTextColor(Color @c)
		{
		}
		/// <summary>
		/// Sets the current color used to render the caret.
		/// </summary>
		public void setCaretColor(Color @c)
		{
		}
示例#20
0
		/// <summary>
		/// Sets the foreground color for selected cells.
		/// </summary>
		public void setSelectionForeground(Color @selectionForeground)
		{
		}
示例#21
0
		/// <summary>
		/// Sets the background color for selected cells.
		/// </summary>
		public void setSelectionBackground(Color @selectionBackground)
		{
		}
		/// <summary>
		/// Sets the color the text is drawn with when the node is selected.
		/// </summary>
		public void setTextSelectionColor(Color @newColor)
		{
		}
示例#23
0
 /// <summary>
 /// Sets the foreground color of this component.
 /// </summary>
 public void setForeground(Color @c)
 {
 }
示例#24
0
		/// <summary>
		/// Sets the color used to draw grid lines to <code>gridColor</code> and redisplays.
		/// </summary>
		public void setGridColor(Color @gridColor)
		{
		}
示例#25
0
		/// <summary>
		/// Sets the paint mode of this graphics context to alternate between
		/// this graphics context's current color and the new specified color.
		/// </summary>
		abstract public void setXORMode(Color @c1);
		/// <summary>
		/// Sets the current color used to render the
		/// disabled text.
		/// </summary>
		public void setDisabledTextColor(Color @c)
		{
		}
示例#27
0
		/// <summary>
		/// Draws as much of the specified area of the specified image as is
		/// currently available, scaling it on the fly to fit inside the
		/// specified area of the destination drawable surface.
		/// </summary>
		abstract public bool drawImage(Image @img, int @dx1, int @dy1, int @dx2, int @dy2, int @sx1, int @sy1, int @sx2, int @sy2, Color @bgcolor, ImageObserver @observer);
		/// <summary>
		/// Sets the current color used to render the selection.
		/// </summary>
		public void setSelectionColor(Color @c)
		{
		}
示例#29
0
		/// <summary>
		/// Finds a color in the system properties.
		/// </summary>
		public Color getColor(string @nm, Color @v)
		{
			return default(Color);
		}