正在加载...
 
恶战  

前前后后从准备到结束历时15天的考试终于告一段落,不能不说这是一场恶战,而在这场恶战中,我方战士发扬艰苦奋斗不屈不挠的精神,搬到了n座大山,终于赢得胜利。欢呼吧,战士!

阅读全文...
标签:生活乐趣,考试复习 | 浏览数(898) | 评论数(3) | 2006-11-05
写点写点  

      十一回碇峋蜕享的次”底ƒ得好了。或許是忙的原因吧。
  招聘一波接著一波,一轉眼班裏同ŒWŽ缀醵加凶怕淞恕9ぷ鞅Q锌佳谐?Dagger;亩加辛耍牛谩L娲蠹腋吲d!
  自己的生活也?euro;定下砹耍?OElig;W說你就在ŒW校再憋ƒ扇臧桑纯囱芯可鲰后是呆子?euro;是黑山老妖。呵呵,偶自己感覺在這‚€不太複雜又很清靜的地方再呆ƒ赡耆晏找碧找鼻椴偻茫╚_^),何›rŒ?#382;室?mdash;目挺多,ƒ赡?bull;r間一晃而過~~
  說起Œ?#382;室,…⑴c的第一‚€?mdash;目就有點不?tilde;,“Q了N多programmer不說,能›件工程的角度講,很不符合開發流程。需求如此複雜晦鞘?nbsp;‘了發“]我‚ƒ的主觀能„有裕恳只蚪档烷_發成本?不知道。-_-!! 而且這‚€臺ž车捻—目用的是繁文,很多字不認識不•?OElig;‘,逼得我打字都得用繁體。不過?euro;好,?rsaquo;過這一‚€多禮拜的夜‘穑K于小有成就,敲出Ž浊写a,Œ現了自己?ldquo;?Yuml;的那一部分的功能。

      原本想買‚€筆?rsaquo;本的,以前老感覺自己的臺式™C不‰蚍奖悖荒苣庙拿去。現在看硪灿貌蛔帕耍?OElig;‹室一台,Œ?#382;室一台,ƒ?sbquo;€加起硪菜闶且惶üP?rsaquo;本了。 

    

阅读全文...
浏览数(871) | 评论数(5) | 2006-10-19
一眼万年  

歌曲:一眼万年
歌手:s.h.e 专辑:天外飞仙片头曲

selina

泪有点咸有点甜
你的胸膛吻着我的侧脸
回头看踏过的雪
慢慢融化成草原
而我就像你没有一秒曾后悔

阅读全文...
标签:Songs I like | 浏览数(1015) | 评论数(1) | 2006-10-11
做爱做的事!  

      今天同学问起我如何局部刷新页面,于是我从前台Ajax技术应用到后台java servlet代码编写 滔滔不绝地和他说了一大堆东西。

阅读全文...
标签:生活乐趣 | 浏览数(1065) | 评论数(4) | 2006-09-25
祝所有的朋友都有光明的明天!  

这两天已经有好几个好兄弟相继离偶而去(去上海工作实习),吾难受不已。

以后的大四生活里再也没有人陪偶去大大吃饭,去虐待台球,一起评论“美女”了,长叹。。。

没有不散的筵席,迟早大家要各自单飞的。

我的兄弟们,去了上海(不管是花旗还是海龙)可要好好工作(也别太卖命),注意身体,打出自己的一片天地!

 

偶在导师的实验室也开始做项目了,想必也不会轻松(光 需求说明书就70多页),十一估计也没有假期了。埋头奋斗ing!

 

 

浏览数(946) | 评论数(4) | 2006-09-21
生活就此改变  

我只能郑重的说:考研路上我停了车,转向了保研路。

考pkuCS和保本系两个选择,权衡利弊之后,我最终选择了后者。

有人说我放弃自己的pku之梦是懦夫的行为,也有人说这是明智的选择。不论别人怎么说,自己的事自己做主!

我要争取的一切就是时间!

从这学期开始,我就要进入导师的实验室了,这是我自己申请的,因为我觉得大四的时间花在提高自己的实际能力更有价值,况且这样研一之后我已经有了两年的项目经验和科研能力,按学校规定,我们研二就已经可以离校实习了。这相当于我用一年的时间完成研究生学业,时间比什么都重要,时间就是机遇,我相信自己选择的路是自己愿意走的并能够踏踏实实走好的,不后悔!

 

 

标签:生活乐趣 | 浏览数(1113) | 评论数(5) | 2006-09-17
忘了你忘了我  

忘了你忘了我(王杰)


当你说要走我不想挥手的时候
爱情终究是一场空
谁说我俩的过去尽在不言中
别忘了我曾拥有你你也曾爱过我
当你留给我我不想接受的伤痛
爱情到头来还是梦
别说我俩的世界有太多不同
就说你已经忘了我你就要离开我
谁能够告诉我我是否付出太多
就当我从来没有过
还是消失在我心头
谁曾经提醒我我的爱没有把握
就当我从来没有过
还是忘了你忘了我

标签:生活乐趣,Songs I like | 浏览数(1409) | 评论数(3) | 2006-09-02
高像素清晰缩略图生成(java)  

在公司实习的时候还是练了不少代码的,觉得这个类算得上写的比较通用吧,其中也借鉴了别人的算法,贴出来大家共享共同进步。

package com.modules.image;
import com.modules.basicObject;
import java.net.*;
import java.io.*;
import java.awt.image.*;
import java.awt.*;
import com.sun.image.codec.jpeg.*;
import javax.imageio.ImageIO;
import javax.imageio.stream.*;
import com.book.db.dbOperator;
import java.sql.ResultSet;
import java.util.*;
import javax.imageio.stream.*;
import javax.imageio.*;

/**
 * <p>Title: Image Process</p>
 * <p>Copyright: Copyright (c) 2006</p>
 *
 * @Johbin,Wang
 * @version 1.0
 */

public class imager extends basicObject {
    private Image org_image = null;
    private BufferedImage bfd_image = null;
    private BufferedImage tag = null;
    private String imageName = "";
    private String sourceFileURI ="";
    private String desFileURI = "";
    private String imageType = "jpeg";//defaultf format
    private String str_uri=null;
    public imager() {
    }

    public boolean setImage(String m_id,String type)
    {
        try{
            str_uri = getAppPath() + "files/images/";
            imageType = type;
            imageName = m_id + "." + imageType;
            str_uri += imageName;
            sourceFileURI = str_uri;
            File _file = new File(str_uri);
      org_image = javax.imageio.ImageIO.read(_file);
            return true;
        }
        catch(Exception e)
        {
            this.AddError("set image", e.getMessage()+"<br />"+imageName+"<br />"+str_uri+"<br />");
            return false;
        }
    }
    //generate resized image, and put it under images/thumb directory
    //add record into database
    //return image id if successfully
  
    public String resize(int width,int height,String pos){
        try
        {
            if(org_image!=null)
            {
                BufferedImage temp = null;
                desFileURI = getAppPath() + "files/images/thumb/"+"SM"+imageName.substring(2); //destination image URI
               
                int _width = org_image.getWidth(null);
                int _height = org_image.getHeight(null);
               
               
                FileOutputStream out=new FileOutputStream(desFileURI); 
                JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
               
                if(_width<=width&&_height<=height)
                {
                 
                    if(_width==width&&_height==height)
                    {
                        FileInputStream fileis = new FileInputStream(sourceFileURI);
                        FileOutputStream fileos = new FileOutputStream(desFileURI);
                        int count;
                        byte[] buffer = new byte[100];
                        while(-1 != (count = fileis.read(buffer))){
                            fileos.write(buffer);
                            fileos.flush();
                        }
                        fileis.close();
                        fileos.close();
                    }
                   else
                   {
                        tag = new BufferedImage(width,height,BufferedImage.TYPE_INT_RGB);
                        tag.getGraphics().drawImage(org_image,(width-_width)/2,(height-_height)/2,_width,_height,null);
                        //encoder.encode(tag);
                        //out.close();
                        ImageIO.write(temp,imageType,new File(desFileURI));
                   }
                }
                else if(_width>width&&_height<=height)
                {
                     //scale the source image
                        tag = new BufferedImage(_width,height,BufferedImage.TYPE_INT_RGB);
                        tag.getGraphics().drawImage(org_image,0,(height-_height)/2,_width,_height,null);

                        //clip image
                        if(pos.equalsIgnoreCase("TL")||pos.equalsIgnoreCase("ML")||pos.equalsIgnoreCase("BL"))
                        {
                            temp = tag.getSubimage(0,0, width,height); 
                        }
                        else if(pos.equalsIgnoreCase("TM")||pos.equalsIgnoreCase("MM")||pos.equalsIgnoreCase("BM"))
                        {
                            temp = tag.getSubimage((_width-width)/2,0, width,height);
                        }
                        else
                        {
                            temp = tag.getSubimage(_width-width,0, width,height);  
                        }
                        encoder.encode(temp);
                        //out.close();
                        //ImageIO.write(temp,imageType,new File(desFileURI));
                }
                else if(_height>height&&_width<=width)
                {
                    //scale the source image
                        tag = new BufferedImage(width,_height,BufferedImage.TYPE_INT_RGB);
                        tag.getGraphics().drawImage(org_image,(width-_width)/2,0,_width,_height,null);

                        //clip image
                        if(pos.equalsIgnoreCase("TL")||pos.equalsIgnoreCase("TM")||pos.equalsIgnoreCase("TR"))
                        {
                            temp = tag.getSubimage(0,0, width,height); 
                        }
                        else if(pos.equalsIgnoreCase("ML")||pos.equalsIgnoreCase("MM")||pos.equalsIgnoreCase("MR"))
                        {
                            temp = tag.getSubimage(0,(_height-height)/2, width,height);
                        }
                        else
                        {
                            temp = tag.getSubimage(0,_height-height, width,height);  
                        }
                        encoder.encode(temp);
                       //out.close();
                        ImageIO.write(temp,imageType,new File(desFileURI));
                }
                else
                {   
                   if(_width==_height)
                    {

                       if(_width>width)// just scale source image, no clipping.
                        {
                         
                            tag = new BufferedImage(width,height,BufferedImage.TYPE_INT_RGB);
                            tag.getGraphics().drawImage(org_image,0,0,width,height,null);
                            encoder.encode(tag);
                          //out.close();
                            //ImageIO.write(tag,imageType,new File(desFileURI));
                        }

                    }
                    else if(_width>_height)
                    {
                        if(imageType.equals("gif")||imageType.equals("GIF")){
                            //scale the source image
                            tag = new BufferedImage(Math.round((float)_width/_height*height),height,BufferedImage.TYPE_INT_RGB);
                            tag.getGraphics().drawImage(org_image,0,0,Math.round((float)_width/_height*height),height,null);
       
       this.AddError("width","width= "+Math.round((float)_width/_height*height)+"height="+height);
                            //clip image
                            if(pos.equalsIgnoreCase("TL")||pos.equalsIgnoreCase("ML")||pos.equalsIgnoreCase("BL"))
                            {
                                temp = tag.getSubimage(0,0, width,height); 
                            }
                            else if(pos.equalsIgnoreCase("TM")||pos.equalsIgnoreCase("MM")||pos.equalsIgnoreCase("BM"))
                            {
                                temp = tag.getSubimage(Math.round(((float)_width/_height*height-width)/2),0, width,height);
                            }
                            else
                            {
                                temp = tag.getSubimage(Math.round(((float)_width/_height*height-width)),0, width,height);  
                            }
                            encoder.encode(temp);
                      //out.close();
                            //ImageIO.write(temp,imageType,new File(desFileURI));
                        }
                        else{
                            ///////scale the image with a high quality//////////
                            tag = new BufferedImage(_width,_height,BufferedImage.TYPE_INT_RGB);
                            tag.getGraphics().drawImage(org_image,0,0,_width,_height,null);
                           
                            BufferedImage rtBf = null;
                            ImageScale is = new ImageScale();
                            rtBf = is.imageZoomOut(tag,Math.round((float)_width/_height*height),height);
                           
                            //this.AddError("width","scale width= "+Math.round((float)_width/_height*height)+"  "+"height="+ height);
                            //clip image
                            if(pos.equalsIgnoreCase("TL")||pos.equalsIgnoreCase("ML")||pos.equalsIgnoreCase("BL"))
                            {
                                temp = rtBf.getSubimage(0,0, width,height); 
                            }
                            else if(pos.equalsIgnoreCase("TM")||pos.equalsIgnoreCase("MM")||pos.equalsIgnoreCase("BM"))
                            {
                                temp = rtBf.getSubimage(Math.round(((float)_width/_height*height-width)/2),0, width,height);
                            }
                            else
                            {
                                temp = rtBf.getSubimage(Math.round(((float)_width/_height*height-width)),0, width,height);  
                            }
                           
                            ImageIO.write(temp,imageType,new File(desFileURI));   
                        }
                    }
                    else
                    {
                       if(imageType.equals("gif")||imageType.equals("GIF")){
                            //scale the source image
                            tag = new BufferedImage(width,Math.round((float)_height/_width*width),BufferedImage.TYPE_INT_RGB);
                            tag.getGraphics().drawImage(org_image,0,0,width,Math.round((float)_height/_width*width),null);

                            //clip image
                            if(pos.equalsIgnoreCase("TL")||pos.equalsIgnoreCase("TM")||pos.equalsIgnoreCase("TR"))
                            {
                                temp = tag.getSubimage(0,0, width,height);
                            }
                            else if(pos.equalsIgnoreCase("ML")||pos.equalsIgnoreCase("MM")||pos.equalsIgnoreCase("MR"))
                            {
                                temp = tag.getSubimage(0,Math.round(((float)_height/_width*width-height)/2), width,height);   
                            }
                            else
                            {
                                temp = tag.getSubimage(0,Math.round((float)_height/_width*width-height), width,height);  
                            }
                           encoder.encode(temp);
                      // out.close();
                            //ImageIO.write(temp,imageType,new File(desFileURI));
                       }
                       else{
                            ///////scale the image with a high quality//////////
                            tag = new BufferedImage(_width,_height,BufferedImage.TYPE_INT_RGB);
                            tag.getGraphics().drawImage(org_image,0,0,_width,_height,null);
                           
                            BufferedImage rtBf = null;
                            ImageScale is = new ImageScale();
                            rtBf = is.imageZoomOut(tag,width,Math.round((float)_height/_width*width));
                           
                            //clip image
                            if(pos.equalsIgnoreCase("TL")||pos.equalsIgnoreCase("TM")||pos.equalsIgnoreCase("TR"))
                            {
                                temp = rtBf.getSubimage(0,0, width,height);
                            }
                            else if(pos.equalsIgnoreCase("ML")||pos.equalsIgnoreCase("MM")||pos.equalsIgnoreCase("MR"))
                            {
                                temp = rtBf.getSubimage(0,Math.round(((float)_height/_width*width-height)/2), width,height);   
                            }
                            else
                            {
                                temp = rtBf.getSubimage(0,Math.round((float)_height/_width*width-height), width,height);  
                            }
    //                        encoder.encode(temp);
                        //out.close();
                            ImageIO.write(temp,imageType,new File(desFileURI));
                       }
                    }

                }
                 out.close();
                 return "SM"+imageName.substring(2,9);
            }
           else{
             this.AddError("Error","the image format is illegal");
             return "fail";
            }
           
           
        }catch(Exception e)
        {
            this.AddError("Scale Image Fail", e.toString()+" ");
            return "fail";
        }
    }
   
   
    ////inner class for filter and scale image with a high quality.
    class ImageScale {
 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;

 
  
 //Use Lanczos filter to replace the original algorithm for image scaling. Lanczos improves quality of the scaled image
 
 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);

 } // end of Lanczos()

 //
 //   Assumption: same horizontal and vertical scaling factor
 //
 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;
 }

}
}

标签:编程技术,内功系列 | 浏览数(2056) | 评论数(0) | 2006-08-18

Powered by Haiwit