Save bytes Image in the Application Server Using java

import java.util.*;
import java.sql.*;
import java.lang.Integer;
import java.text.DecimalFormat;
import java.text.*;

import java.awt.Color;
import java.awt.image.BufferedImage;
import javax.imageio.ImageIO;

import javax.imageio.ImageIO;

import java.awt.image.BufferedImage;
import java.awt.Dimension;

import org.apache.poi.hslf.usermodel.SlideShow;
import org.apache.poi.hslf.model.Slide;
import org.apache.poi.hslf.model.Fill;
import org.apache.poi.hslf.model.Picture;
import org.apache.poi.hslf.model.TextBox;
//import org.apache.commons.codec.binary.Base64;
import org.apache.poi.hslf.HSLFSlideShow;

public class SaveImg

public DBConnection dbCon;
public Connection c;
public List finallist ;

public List arrList;

public List arrListBullet ;
public List arrListSpark ;

public Vector columnTypeCategorical;
public Vector columnTypeNumeric;

public String strCatFields=””;
public String strNumFields=””;

private SlideShow ppt;
private Slide slide;
private Fill fill;
private int idx;
private FileOutputStream out;

public static Vector vcFileName = new Vector();

public static int i=0;

public void ConnectDatabase()
dbCon = new DBConnection();
c = dbCon.conn;

@param -Query String
@return -array List
public void SaveImages(byte[] bd, int width, int height)

BufferedImage image = new BufferedImage(width, height,
//loop through all the pixels
for (int y=0; y<height; y++) {
for (int x=0; x<width; x++) {
//calculate array offset
int o = (x*4)+(y*width*4);

//set the pixel color
//here we will need to convert
//the byte data to an unsigned
//value using &0xFF before passing
//it to the Color constructor
image.setRGB(x, y, new Color(
bd[o+1]&0xFF, //red
bd[o+2]&0xFF, //green
bd[o+3]&0xFF //blue

//write the image to a file

String tomcatDir = System.getProperty("catalina.home");
File f = new File(tomcatDir+"/webapps/PP/Images/");

String strFileName = "img"+i;
File file = new File(tomcatDir+"/webapps/Images/"+strFileName+".bmp");
try {ImageIO.write(image, "jpg", file);}
catch (IOException e) {e.printStackTrace();}

//empty default constructor
public void CreatePresentations()
CreatePresentation present = new CreatePresentation();
}catch(Exception fnfe){}


/*public void createSlideWithChart(String chartName)
slide = ppt.createSlide();
fill = slide.getBackground().getFill();
idx = ppt.addPicture(new File(chartName), Picture.PNG);
}catch(FileNotFoundException fnfe){}
catch(IOException ioe){}

public void savePPT()
}catch(FileNotFoundException fnfe){}
catch(IOException ioe){}


About ashokabhat

I am a C,C ,JAVA,Adobe Flex,.NET Programmer Currently working as a Software Developer
This entry was posted in Uncategorized and tagged . Bookmark the permalink.

1 Response to Save bytes Image in the Application Server Using java

  1. vpn vs proxy says:

    Another example is when you use public Wi – Fi, knowing your wireless data can be
    sniffed out by criminals. Operates on multiple platforms: be sure that the provider you choose will support both Android VPN
    clients as well as i – Phone VPN clients. Check the connection again and see if the GUI steps
    are available.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s