`
philip01
  • 浏览: 47132 次
  • 来自: ...
社区版块
存档分类
最新评论

图片合并

阅读更多

package com.overseas;

import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.text.SimpleDateFormat;
import java.util.Calendar;

import javax.imageio.ImageIO;
import javax.swing.ImageIcon;

/**
 * @version 1.0
 * @since 2009-07-02
 * @author springmvc2006@sina.com
 *
 */
public class AggregaPicture {

 private static int alpha = 1000; // 0, 100, 1000, 10000

 private static String pictureType = "png"; // png, jpg

 public static void main(String[] args) throws Exception {

  File workFile = new File("d:/img/work");
  builderPicture(new File(workFile, "1.jpg"), "d:/img/work/", 20, 20);
  transferSize(workFile, 600, 600); // 要转的图片路径
  AggregaPicture aggregaPicture = new AggregaPicture();
  File temp = new File(workFile.getParent() + "/temp"); // 临时文件


  aggregaPicture.task(new File("d:/img/aggregaPictureFileName20@20."
    + pictureType), temp, 20, 20);
/*  aggregaPicture.task(new File("d:/img/aggregaPictureFileName3@3."
    + pictureType), temp, 3, 3);
  aggregaPicture.task(new File("d:/img/aggregaPictureFileName9@1."
    + pictureType), temp, 9, 1);
  aggregaPicture.task(new File("d:/img/aggregaPictureFileName4@2."
    + pictureType), temp, 4, 2);
  aggregaPicture.task(new File("d:/img/aggregaPictureFileName3@2."
    + pictureType), temp, 3, 2);
  aggregaPicture.deleteImage(temp);*/

 }

 public static void builderPicture(File file, String newPath, int colNum, int rowNum) {
  for(int i=0; i<colNum*rowNum; i++){
   copy(file, newPath+i+"."+pictureType);
  }
 }

 /**
  * @param width
  * @param height
  */
 public void task(File aggregaPictureFileName, File file, int rowNum,
   int colNum) throws Exception {
  if (!file.exists()) {
   throw new FileNotFoundException();
  }

  File[] files = file.listFiles();

  if (files.length < rowNum * colNum) {
   throw new ArrayIndexOutOfBoundsException();
  }

  ImageIcon rowResultImage = null;
  ImageIcon resultImage = null;
  String imageOneName = null;
  String imageTwoName = null;

  if (colNum > 1) {
   rowResultImage = mergeRow(files, 1, colNum);
   resultImage = rowResultImage;
   for (int i = 2; (i <= rowNum) && (colNum > 1); i++) {
    rowResultImage = mergeRow(files, i, colNum);
    resultImage = mergeCol(resultImage, rowResultImage);
   }
  } else if (colNum == 1) {
   ImageIcon imageIconOne = null;
   ImageIcon imageIconTwo = null;
   imageOneName = files[0].getAbsolutePath();
   imageTwoName = files[1].getAbsolutePath();
   imageIconOne = new ImageIcon(imageOneName);
   imageIconTwo = new ImageIcon(imageTwoName);

   rowResultImage = mergeVertical(imageIconOne, imageIconTwo);
   resultImage = rowResultImage;
   for (int i = 2; i < rowNum; i++) {
    System.out.println("col =" + files[i].getAbsolutePath());
    rowResultImage = new ImageIcon(files[i].getAbsolutePath());
    resultImage = mergeCol(resultImage, rowResultImage);
   }
  }

  saveAggregaPictureFile(resultImage, aggregaPictureFileName);
 }

 public ImageIcon mergeRow(File[] files, int rowNum, int colNum)
   throws Exception {

  ImageIcon imageIconOne = null;
  ImageIcon imageIconTwo = null;
  ImageIcon rowResultImage = null;

  String imageOneName = null;
  String imageTwoName = null;

  imageOneName = files[colNum * (rowNum - 1)].getAbsolutePath();

  System.out.println("rowNum " + rowNum);
  System.out.println(imageOneName);
  imageTwoName = files[colNum * (rowNum - 1) + 1].getAbsolutePath();
  System.out.println(imageTwoName);

  imageIconOne = new ImageIcon(imageOneName);
  imageIconTwo = new ImageIcon(imageTwoName);

  rowResultImage = mergeHorizontal(imageIconOne, imageIconTwo);

  for (int i = 2; i < colNum; i++) {
   imageOneName = files[colNum * (rowNum - 1) + i].getAbsolutePath();
   System.out.println(imageOneName);
   imageIconOne = new ImageIcon(imageOneName);
   rowResultImage = mergeHorizontal(rowResultImage, imageIconOne);
  }

  return rowResultImage;

 }

 public ImageIcon mergeCol(ImageIcon imageOne, ImageIcon imageTwo)
   throws Exception {
  return mergeVertical(imageOne, imageTwo);
 }

 public ImageIcon mergeHorizontal(ImageIcon imageOne, ImageIcon imageTwo)
   throws Exception {
  ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();

  BufferedImage bufferedImage = setAlpha(imageOne);
  int widthOne = bufferedImage.getWidth();
  int heightOne = bufferedImage.getHeight();
  int[] imageArrayOne = new int[widthOne * heightOne];
  imageArrayOne = bufferedImage.getRGB(0, 0, widthOne, heightOne,
    imageArrayOne, 0, widthOne);

  BufferedImage bufferedImageTwo = setAlpha(imageTwo);
  int widthTwo = bufferedImageTwo.getWidth();
  int heightTwo = bufferedImageTwo.getHeight();
  int[] imageArrayTwo = new int[widthTwo * heightTwo];
  imageArrayTwo = bufferedImageTwo.getRGB(0, 0, widthTwo, heightTwo,
    imageArrayTwo, 0, widthTwo);

  // int smallHeightSize = heightOne > heightTwo ? heightTwo : heightOne;

  // 生成新图片
  BufferedImage imageNew = new BufferedImage(widthOne + widthTwo,
    heightOne, BufferedImage.TYPE_INT_RGB);
  imageNew.setRGB(0, 0, widthOne, heightOne, imageArrayOne, 0, widthOne);// 设置左半部分的RGB
  imageNew.setRGB(widthOne, 0, widthTwo, heightTwo, imageArrayTwo, 0,
    widthTwo);
  ImageIO.write(imageNew, pictureType, byteArrayOutputStream);// 写图片

  File file = new File("d:/img/mergeHorizontal");
  if (!file.exists()) {
   file.mkdirs();
  }
  ImageIO.write(imageNew, pictureType, new File("d:/img/mergeHorizontal/"
    + getSystemDate() + "." + pictureType));

  ImageIcon tempIcon = new ImageIcon(byteArrayOutputStream.toByteArray());
  return tempIcon;
 }

 public ImageIcon mergeVertical(ImageIcon imageOne, ImageIcon imageTwo)
   throws Exception {
  ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();

  BufferedImage bufferedImage = setAlpha(imageOne);
  int widthOne = bufferedImage.getWidth();
  int heightOne = bufferedImage.getHeight();


  BufferedImage bufferedImageTwo = setAlpha(imageTwo);
  int widthTwo = bufferedImageTwo.getWidth();
  int heightTwo = bufferedImageTwo.getHeight();
  int[] imageArrayTwo = new int[widthTwo * heightTwo];
  

  // 生成新图片
  BufferedImage imageNew = new BufferedImage(widthOne, heightOne
    + heightTwo, BufferedImage.TYPE_INT_RGB);
  
  
  imageArrayTwo = bufferedImageTwo.getRGB(0, 0, widthTwo, heightTwo,
    imageArrayTwo, 0, widthTwo);
  imageNew.setRGB(0, heightOne, widthTwo, heightTwo, imageArrayTwo, 0,
    widthTwo);
  imageArrayTwo = null;
  bufferedImageTwo = null;
  
  
  int[] imageArrayOne = new int[widthOne * heightOne];
  imageArrayOne = bufferedImage.getRGB(0, 0, widthOne, heightOne,
    imageArrayOne, 0, widthOne);
  imageNew.setRGB(0, 0, widthOne, heightOne, imageArrayOne, 0, widthOne);
  imageArrayOne = null;
  bufferedImage = null;


  // imageNew.setRGB(width,0,width,height,imageArrayTwo,0,width);

  ImageIO.write(imageNew, pictureType, byteArrayOutputStream);// 写图片

  File file = new File("d:/img/mergeVertical");
  if (!file.exists()) {
   file.mkdirs();
  }
  ImageIO.write(imageNew, pictureType, new File("d:/img/mergeVertical/"
    + getSystemDate() + "." + pictureType));
  ImageIcon tempIcon = new ImageIcon(byteArrayOutputStream.toByteArray());
  return tempIcon;
 }

 private BufferedImage setAlpha(ImageIcon imageIcon) {
  BufferedImage bufferedImage = new BufferedImage(imageIcon
    .getIconWidth(), imageIcon.getIconHeight(),
    BufferedImage.TYPE_4BYTE_ABGR);
  try {

   Graphics2D g2D = (Graphics2D) bufferedImage.getGraphics();
   g2D.drawImage(imageIcon.getImage(), 0, 0, imageIcon
     .getImageObserver());
   // int alpha = 100;
   for (int j1 = bufferedImage.getMinY(); j1 < bufferedImage
     .getHeight(); j1++) {
    for (int j2 = bufferedImage.getMinX(); j2 < bufferedImage
      .getWidth(); j2++) {
     int rgb = bufferedImage.getRGB(j2, j1);
     int R = (rgb & 0xff0000) >> 16;
     int G = (rgb & 0xff00) >> 8;
     int B = (rgb & 0xff);

     rgb = ((alpha + 1) << 24) | (rgb & 0x00ffffff);

     bufferedImage.setRGB(j2, j1, rgb);
    }
   }
   g2D.dispose();
  } catch (Exception e) {
   e.printStackTrace();
  }

  return bufferedImage;

 }

 public void saveAggregaPictureFile(ImageIcon imageIcon,
   File aggregaPictureFileName) throws Exception {
  BufferedImage bufferedImage = new BufferedImage(imageIcon
    .getIconWidth(), imageIcon.getIconHeight(),
    BufferedImage.TYPE_4BYTE_ABGR);
  Graphics2D g2D = (Graphics2D) bufferedImage.getGraphics();
  g2D.drawImage(imageIcon.getImage(), 0, 0, imageIcon.getImageObserver());
  // 循环每一个像素点,改变像素点的Alpha值
  // int alpha = 100;
  for (int j1 = bufferedImage.getMinY(); j1 < bufferedImage.getHeight(); j1++) {
   for (int j2 = bufferedImage.getMinX(); j2 < bufferedImage
     .getWidth(); j2++) {
    int rgb = bufferedImage.getRGB(j2, j1);
    int R = (rgb & 0xff0000) >> 16;
    int G = (rgb & 0xff00) >> 8;
    int B = (rgb & 0xff);

    //rgb = ((alpha + 1) << 24) | (rgb & 0x00ffffff);

    bufferedImage.setRGB(j2, j1, rgb);

   }
  }
  g2D.drawImage(bufferedImage, 0, 0, imageIcon.getImageObserver());

  // 生成图片为PNG

  ImageIO.write(bufferedImage, pictureType, aggregaPictureFileName);
  g2D.dispose();
 }

 public static void transferSize(File imgDir, int width, int heigth)
   throws Exception {
  if (!imgDir.exists()) {
   throw new FileNotFoundException();
  }

  String tempDir = imgDir.getParent() + "/temp/";
  File file = new File(tempDir);
  if (!file.exists()) {
   file.mkdirs();
  }

  File[] imgFiles = imgDir.listFiles();

  for (int i = 0; i < imgFiles.length; i++) {
   if (imgFiles[i].isFile()) {
    ScaleImage is = new ScaleImage();
    try {
     System.out.println(imgFiles[i].getAbsolutePath());
     is.saveImageAsJpg(imgFiles[i].getAbsolutePath(), tempDir
       + imgFiles[i].getName(), width, heigth);
    } catch (Exception e) {
     e.printStackTrace();
    }

   }
  }
 }

 public static void copy(String oldPath, String newPath) {
  File oldfile = new File(oldPath);
  copy(oldfile, newPath);
 }

 public static void copy(File oldfile, String newPath) {
  InputStream inStream = null;
  FileOutputStream fs = null;
  try {
   int bytesum = 0;
   int byteread = 0;
   if (oldfile.exists()) {
    inStream = new FileInputStream(oldfile);
    fs = new FileOutputStream(newPath);
    byte[] buffer = new byte[1024];
    while ((byteread = inStream.read(buffer)) != -1) {
     bytesum += byteread;
     fs.write(buffer, 0, byteread);
    }
    inStream.close();
    fs.close();
   }
  } catch (Exception e) {
   System.out.println("error  ");
   e.printStackTrace();
  }finally{
   if(inStream != null){
    try {
     inStream.close();
     inStream = null;
    } catch (IOException e) {
     e.printStackTrace();
    }
   }
   
   if(fs != null){
    try {
     fs.close();
     fs = null;
    } catch (IOException e) {
     e.printStackTrace();
    }
   }
  }
 }

 public void deleteImage(File temp) {
  if (temp.exists()) {

   File[] tempImages = temp.listFiles();
   for (int i = 0; i < tempImages.length; i++) {
    tempImages[i].delete();
   }
  }

 }

 public static String getSystemDate() {
  Calendar cal = Calendar.getInstance();
  SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss");
  String mDateTime = formatter.format(cal.getTime());
  return mDateTime;
 }

}

 

package com.overseas;

import java.awt.image.BufferedImage;
import java.io.File;

import javax.imageio.ImageIO;

/**
 * springmvc2006@sina.com
 *
 */
public class ScaleImage {
 
 
 private int width;  
  
    private int height;  
 
    private int scaleWidth;  
 
    double support = (double) 3.0;  
 
    double PI = (double) 3.14159265358978;  
 
    double[] contrib;  
 
    double[] normContrib;  
 
    double[] tmpContrib;  
 
    int startContrib, stopContrib;  
 
    int nDots;  
 
    int nHalfDots;  
 

    public static void main(String[] args) {  
        ScaleImage is = new ScaleImage();  
        try {  
            is.saveImageAsJpg("d:/img/temp/3.jpg", "d:/img/temp/3.bak.jpg", 200, 200);  
        } catch (Exception e) {  
            // TODO Auto-generated catch block  
            e.printStackTrace();  
        }  
    }  
 
    // fromFileStr原图片地址,saveToFileStr生成缩略图地址,formatWideth生成图片宽度,formatHeight高度  
    public void saveImageAsJpg(String fromFileStr, String saveToFileStr,  
            int formatWideth, int formatHeight) throws Exception {  
        BufferedImage srcImage;  
        File saveFile = new File(saveToFileStr);  
        File fromFile = new File(fromFileStr);  
        srcImage = javax.imageio.ImageIO.read(fromFile); // construct image  
        int imageWideth = srcImage.getWidth(null);  
        int imageHeight = srcImage.getHeight(null);  
        int changeToWideth = 0;  
        int changeToHeight = 0;  
        if (imageWideth > 0 && imageHeight > 0) {  
            // flag=true;  
            if (imageWideth / imageHeight >= formatWideth / formatHeight) {  
                if (imageWideth > formatWideth) {  
                    changeToWideth = formatWideth;  
                    changeToHeight = (imageHeight * formatWideth) / imageWideth;  
                } else {  
                    changeToWideth = imageWideth;  
                    changeToHeight = imageHeight;  
                }  
            } else {  
                if (imageHeight > formatHeight) {  
                    changeToHeight = formatHeight;  
                    changeToWideth = (imageWideth * formatHeight) / imageHeight;  
                } else {  
                    changeToWideth = imageWideth;  
                    changeToHeight = imageHeight;  
                }  
            }  
        }  
 
        srcImage = imageZoomOut(srcImage, changeToWideth, changeToHeight);  
        ImageIO.write(srcImage, "JPEG", saveFile);  
    }  
 
    public BufferedImage imageZoomOut(BufferedImage srcBufferImage, int w, int h) {  
        width = srcBufferImage.getWidth();  
        height = srcBufferImage.getHeight();  
        scaleWidth = w;  
 
        if (DetermineResultSize(w, h) == 1) {  
            return srcBufferImage;  
        }  
        CalContrib();  
        BufferedImage pbOut = HorizontalFiltering(srcBufferImage, w);  
        BufferedImage pbFinalOut = VerticalFiltering(pbOut, h);  
        return pbFinalOut;  
    }  
 
    /** *//** 
     * 决定图像尺寸 
     */ 
    private int DetermineResultSize(int w, int h) {  
        double scaleH, scaleV;  
        scaleH = (double) w / (double) width;  
        scaleV = (double) h / (double) height;  
        // 需要判断一下scaleH,scaleV,不做放大操作  
        if (scaleH >= 1.0 && scaleV >= 1.0) {  
            return 1;  
        }  
        return 0;  
 
    } // end of DetermineResultSize()  
 
    private double Lanczos(int i, int inWidth, int outWidth, double Support) {  
        double x;  
 
        x = (double) i * (double) outWidth / (double) inWidth;  
 
        return Math.sin(x * PI) / (x * PI) * Math.sin(x * PI / Support)  
                / (x * PI / Support);  
 
    }  
 
    private void CalContrib() {  
        nHalfDots = (int) ((double) width * support / (double) scaleWidth);  
        nDots = nHalfDots * 2 + 1;  
        try {  
            contrib = new double[nDots];  
            normContrib = new double[nDots];  
            tmpContrib = new double[nDots];  
        } catch (Exception e) {  
            System.out.println("init   contrib,normContrib,tmpContrib" + e);  
        }  
 
        int center = nHalfDots;  
        contrib[center] = 1.0;  
 
        double weight = 0.0;  
        int i = 0;  
        for (i = 1; i <= center; i++) {  
            contrib[center + i] = Lanczos(i, width, scaleWidth, support);  
            weight += contrib[center + i];  
        }  
 
        for (i = center - 1; i >= 0; i--) {  
            contrib[i] = contrib[center * 2 - i];  
        }  
 
        weight = weight * 2 + 1.0;  
 
        for (i = 0; i <= center; i++) {  
            normContrib[i] = contrib[i] / weight;  
        }  
 
        for (i = center + 1; i < nDots; i++) {  
            normContrib[i] = normContrib[center * 2 - i];  
        }  
    } // end of CalContrib()  
 
    // 处理边缘  
    private void CalTempContrib(int start, int stop) {  
        double weight = 0;  
 
        int i = 0;  
        for (i = start; i <= stop; i++) {  
            weight += contrib[i];  
        }  
 
        for (i = start; i <= stop; i++) {  
            tmpContrib[i] = contrib[i] / weight;  
        }  
 
    } // end of CalTempContrib()  
 
    private int GetRedValue(int rgbValue) {  
        int temp = rgbValue & 0x00ff0000;  
        return temp >> 16;  
    }  
 
    private int GetGreenValue(int rgbValue) {  
        int temp = rgbValue & 0x0000ff00;  
        return temp >> 8;  
    }  
 
    private int GetBlueValue(int rgbValue) {  
        return rgbValue & 0x000000ff;  
    }  
 
    private int ComRGB(int redValue, int greenValue, int blueValue) {  
 
        return (redValue << 16) + (greenValue << 8) + blueValue;  
    }  
 
    // 行水平滤波  
    private int HorizontalFilter(BufferedImage bufImg, int startX, int stopX,  
            int start, int stop, int y, double[] pContrib) {  
        double valueRed = 0.0;  
        double valueGreen = 0.0;  
        double valueBlue = 0.0;  
        int valueRGB = 0;  
        int i, j;  
 
        for (i = startX, j = start; i <= stopX; i++, j++) {  
            valueRGB = bufImg.getRGB(i, y);  
 
            valueRed += GetRedValue(valueRGB) * pContrib[j];  
            valueGreen += GetGreenValue(valueRGB) * pContrib[j];  
            valueBlue += GetBlueValue(valueRGB) * pContrib[j];  
        }  
 
        valueRGB = ComRGB(Clip((int) valueRed), Clip((int) valueGreen),  
                Clip((int) valueBlue));  
        return valueRGB;  
 
    } // end of HorizontalFilter()  
 
    // 图片水平滤波  
    private BufferedImage HorizontalFiltering(BufferedImage bufImage, int iOutW) {  
        int dwInW = bufImage.getWidth();  
        int dwInH = bufImage.getHeight();  
        int value = 0;  
        BufferedImage pbOut = new BufferedImage(iOutW, dwInH,  
                BufferedImage.TYPE_INT_RGB);  
 
        for (int x = 0; x < iOutW; x++) {  
 
            int startX;  
            int start;  
            int X = (int) (((double) x) * ((double) dwInW) / ((double) iOutW) + 0.5);  
            int y = 0;  
 
            startX = X - nHalfDots;  
            if (startX < 0) {  
                startX = 0;  
                start = nHalfDots - X;  
            } else {  
                start = 0;  
            }  
 
            int stop;  
            int stopX = X + nHalfDots;  
            if (stopX > (dwInW - 1)) {  
                stopX = dwInW - 1;  
                stop = nHalfDots + (dwInW - 1 - X);  
            } else {  
                stop = nHalfDots * 2;  
            }  
 
            if (start > 0 || stop < nDots - 1) {  
                CalTempContrib(start, stop);  
                for (y = 0; y < dwInH; y++) {  
                    value = HorizontalFilter(bufImage, startX, stopX, start,  
                            stop, y, tmpContrib);  
                    pbOut.setRGB(x, y, value);  
                }  
            } else {  
                for (y = 0; y < dwInH; y++) {  
                    value = HorizontalFilter(bufImage, startX, stopX, start,  
                            stop, y, normContrib);  
                    pbOut.setRGB(x, y, value);  
                }  
            }  
        }  
 
        return pbOut;  
 
    } // end of HorizontalFiltering()  
 
    private int VerticalFilter(BufferedImage pbInImage, int startY, int stopY,  
            int start, int stop, int x, double[] pContrib) {  
        double valueRed = 0.0;  
        double valueGreen = 0.0;  
        double valueBlue = 0.0;  
        int valueRGB = 0;  
        int i, j;  
 
        for (i = startY, j = start; i <= stopY; i++, j++) {  
            valueRGB = pbInImage.getRGB(x, i);  
 
            valueRed += GetRedValue(valueRGB) * pContrib[j];  
            valueGreen += GetGreenValue(valueRGB) * pContrib[j];  
            valueBlue += GetBlueValue(valueRGB) * pContrib[j];  
            // System.out.println(valueRed+"->"+Clip((int)valueRed)+"<-");  
            //     
            // System.out.println(valueGreen+"->"+Clip((int)valueGreen)+"<-");  
            // System.out.println(valueBlue+"->"+Clip((int)valueBlue)+"<-"+"-->");  
        }  
 
        valueRGB = ComRGB(Clip((int) valueRed), Clip((int) valueGreen),  
                Clip((int) valueBlue));  
        // System.out.println(valueRGB);  
        return valueRGB;  
 
    } // end of VerticalFilter()  
 
    private BufferedImage VerticalFiltering(BufferedImage pbImage, int iOutH) {  
        int iW = pbImage.getWidth();  
        int iH = pbImage.getHeight();  
        int value = 0;  
        BufferedImage pbOut = new BufferedImage(iW, iOutH,  
                BufferedImage.TYPE_INT_RGB);  
 
        for (int y = 0; y < iOutH; y++) {  
 
            int startY;  
            int start;  
            int Y = (int) (((double) y) * ((double) iH) / ((double) iOutH) + 0.5);  
 
            startY = Y - nHalfDots;  
            if (startY < 0) {  
                startY = 0;  
                start = nHalfDots - Y;  
            } else {  
                start = 0;  
            }  
 
            int stop;  
            int stopY = Y + nHalfDots;  
            if (stopY > (int) (iH - 1)) {  
                stopY = iH - 1;  
                stop = nHalfDots + (iH - 1 - Y);  
            } else {  
                stop = nHalfDots * 2;  
            }  
 
            if (start > 0 || stop < nDots - 1) {  
                CalTempContrib(start, stop);  
                for (int x = 0; x < iW; x++) {  
                    value = VerticalFilter(pbImage, startY, stopY, start, stop,  
                            x, tmpContrib);  
                    pbOut.setRGB(x, y, value);  
                }  
            } else {  
                for (int x = 0; x < iW; x++) {  
                    value = VerticalFilter(pbImage, startY, stopY, start, stop,  
                            x, normContrib);  
                    pbOut.setRGB(x, y, value);  
                }  
            }  
 
        }  
 
        return pbOut;  
 
    } // end of VerticalFiltering()  
 
    int Clip(int x) {  
        if (x < 0)  
            return 0;  
        if (x > 255)  
            return 255;  
        return x;  
    }  

 

分享到:
评论

相关推荐

    批量图片合并器完美版

    图片合并器 完美版 如遇到运行错误,请 安装 Microsoft .NET Framework 2.0 Microsoft .NET Framework 2.0 下载地址: http://www.skycn.com/soft/43774.html 本软件可以进行批量合并图片的工作,没有功能限制...

    C#多张图片合并成一张

    在C#编程环境中,将多张图片合并成一张图片是一个常见的图像处理任务,尤其是在报表生成、拼图制作或社交媒体分享等方面。在这个项目中,我们使用Visual Studio 2013作为开发工具,通过C#语言来实现这个功能。以下是...

    PHP多张图片合并成一张图片合并成九宫格图片.zip

    在这个案例中,我们将主要使用GD库来完成图片合并。 1. **图片读取与创建画布** 使用`imagecreatefromstring()`函数读取单个图片文件,例如: ```php $image = imagecreatefromstring(file_get_contents('path/...

    批量图片合并工具(C#源代码)

    在本文中,我们将深入探讨如何使用C#编程语言来实现批量图片合并的工具。这个工具的目的是将多个图像文件合并成一个单一的图像,通常被称为“拼接”。这对于创建全景图、组合多张照片或者在单个图像中展示一系列图片...

    多张图片合并

    "多张图片合并"这个主题就是关于如何将多个图像整合到一张图片中的技术。这通常涉及到编程和图像处理库的使用,例如Java中的Java Advanced Imaging (JAI) 或者更流行的ImageIO API。 描述中提到的“图片路径数量...

    Java将图片合并为视频

    在Java编程环境中,将一系列图片合并成视频是一个常见的多媒体处理任务。这个项目文件提供了一种实现方式,让我们来深入探讨一下这个过程中的关键知识点。 首先,我们要了解的是Java中的多媒体处理库。在这个项目中...

    [C#、WinForm、.Net] 多个图片合并,Image 合并

    [C#、WinForm、.Net] 多个图片合并,Image 合并,详情见文件内容

    易语言图片合并 拼接工具.exe

    图片合并工具 图片拼接工具 将图片上下拼接或者将图片左右拼接导出 软件由易语言开发 方便日常图片处理

    图片合并器 0.0.5.rar

    《图片合并器 0.0.5:轻松批量合并图像的高效工具》 在数字图像处理领域,有时候我们需要将多张图片合并成一张,以满足特定的创作需求或便于管理和展示。"图片合并器 0.0.5"是一款专为此目的设计的实用工具,它以...

    霄鹞图片合并转PDF助手 v3.3.zip

    霄鹞图片合并转PDF助手是由霄鹞软件工作室开发的一款专门将大量图片文件合并输出到一个PDF文件中的应用软件。该软件界面简洁、易用,合并转换速度快,运行稳定,特别适合将扫描的书籍图片文件制作成PDF格式的电子书...

    UTCOOL(图片合并工具)V1.0中文绿色版

    图片合并工具(UTCOOL)是一款轻巧、绿色,完全免费的图片合并工具,它支持把5张图片合并,并且可以保存到电脑中的任意位置。还可以自定义图片宽度和间隔。 图片合并工具使用方法:首先复制一张图片(网页上的也可以...

    各种图片合并工具处理小工具

    图片合并工具图片合并工具图片合并工具图片合并工具图片合并工具图片合并工具图片合并工具图片合并工具图片合并工具图片合并工具图片合并工具图片合并工具图片合并工具图片合并工具图片合并工具图片合并工具图片合并...

    图片合并工具

    在IT领域,图片处理是一项常见的任务,而"图片合并工具"正是为了满足这一需求而设计的软件。这个工具能够帮助用户将多个图片资源合并成一个单一的文件,从而实现更有效的管理和分享。以下是对这个工具及其功能的详细...

    c#图片合并器

    可将任意文件打成压缩包后与任意图片合并,双击显示图片,改后缀后变成压缩包

    KingPictureMerge(图片合并工具)V3.0.0免费绿色版

    King Picture Merge是一款支持批量操作的图片合并工具,可以快速将文件夹中的图片,按照指定的数量、合并方式、保存类型等进行拼接合并,合并后的图片大小统一,有需要的用户赶紧来下载吧! 【软件功能】 1、绿色...

    小巧的图片合并工具

    小巧的图片合并工具,图片合成软件用于拼合多张图片成一张,支持水平拼合,垂直拼合,多行拼合三种组合方式。rn当图片大小不一致时,采用最大的图片的大小作合并标准。图片合成软件绿色免费,方便大家使用。

    java 操作图片,往图片写字,将多图片合并

    除了往图片上添加文字外,另一个常见的需求就是将多张图片合并成一张。虽然原始代码没有提供合并图片的具体实现,但这里可以提供一种通用的合并策略: #### 合并图片的方法 1. **确定最终图片的尺寸**:首先计算出...

    php图片合并(水印),图片上写字,图片裁剪(原生,自带演示demo)

    本教程主要涉及四个关键知识点:图片合并(作为水印应用)、在图片上写字(自定义字体)、图片裁剪以及PHP环境的设置。我们将逐一详细讲解这些内容。 1. PHP图片合并与水印: 在PHP中,可以使用GD库或Imagick扩展来...

    用java把2个tiff或图片合并成一个tiff或图片

    在Java编程环境中,将两个TIFF(Tagged Image File Format)图像或普通图像合并成一个单一的TIFF或图像文件,需要对图像处理有深入的理解,特别是关于图像格式、颜色模型以及位深度的知识。以下是一些相关的技术要点...

    将多个png图片合并成一个png图片

    通过快速轮动播放来实现,少则几帧,多则几十帧,为了方便管理图片和减少图片文件总的大小,往往需要把这些帧的图像合并到一个文件中-----即把N个大小和格式完全相同的png图片排列合并为一个大的png图片。

Global site tag (gtag.js) - Google Analytics