예제 #1
0
        private void createColorImageThreadTask(BufferedImage imageChunk, int mask, ArrayList <BufferedImage> resultList, int index)
        {
            BufferedImage colorImage = new BufferedImage(imageChunk.getWidth(),
                                                         imageChunk.getHeight(), imageChunk.getType());

            for (int x = 0; x < imageChunk.getWidth(); x++)
            {
                for (int y = 0; y < imageChunk.getHeight(); y++)
                {
                    int pixel = imageChunk.getRGB(x, y) & mask;
                    colorImage.setRGB(x, y, pixel);
                }
            }
            resultList.Add(colorImage);
        }
예제 #2
0
        public virtual BufferedImage applyFilters(BufferedImage source)
        {
            BufferedImage dest = source;

            foreach (BufferedImageOp filter in Filters)
            {
                //if (filter.GetType().Equals(typeof(CurvesImageOp)))
                //	continue;
                dest = filter.filter(dest, null);
            }
            int x = (source.getWidth() - dest.getWidth()) / 2;
            int y = (source.getHeight() - dest.getHeight()) / 2;

            source = new BufferedImage(source.getWidth(), source.getHeight(), source.getType());
            source.getGraphics().drawImage(dest, x, y, null);
            return(source);
        }
예제 #3
0
        private BufferedImage createColorImage(BufferedImage originalImage, int mask)
        {
            //BufferedImage colorImage = new BufferedImage(originalImage.getWidth(),
            //    originalImage.getHeight(), originalImage.getType());

            //for (int x = 0; x < originalImage.getWidth(); x++)
            //{
            //    for (int y = 0; y < originalImage.getHeight(); y++)
            //    {
            //        int pixel = originalImage.getRGB(x, y) & mask;
            //        colorImage.setRGB(x, y, pixel);
            //    }
            //}

            //return colorImage;


            ArrayList <BufferedImage> resultList = new ArrayList <BufferedImage>();
            List <CreateImageThread>  threads    = new List <CreateImageThread>();

            int imgChunkSize = 100;
            ArrayList <BufferedImage> images = this.splitImage(originalImage, imgChunkSize);

            for (int i = 0; i < images.ToList().Count; i++)
            {
                CreateImageThread thread = new CreateImageThread();
                thread.run(images.ElementAt(i), mask, resultList, i);
                threads.Add(thread);
            }
            foreach (CreateImageThread thread in threads)
            {
                thread.ToString();
            }

            BufferedImage resultImage   = new BufferedImage(originalImage.getWidth(), originalImage.getHeight(), originalImage.getType());
            int           howManyOnLine = (int)Math.Sqrt(resultList.ToList().Count);

            for (int i = 0; i < howManyOnLine; i++)
            {
                for (int j = 0; j < howManyOnLine; j++)
                {
                    resultImage.createGraphics().drawImage(resultList.ElementAt(i * howManyOnLine + j), imgChunkSize * i, imgChunkSize * j, null);
                }
            }
            return(resultImage);
        }