|
[x]
Posted via EE Mobile
|
||
Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again. |
||
| Question |
|
[x]
Attachment Details
|
||
|
[x]
The Solution Rating System
|
||
With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.
Your Input Matters If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support. Thank you! |
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: |
<%@ page import="java.io.OutputStream"%>
<%@ page import="java.awt.Color"%>
<%@ page import="java.awt.Graphics"%>
<%@ page import="java.awt.image.BufferedImage"%>
<%@ page import="javax.imageio.ImageIO"%>
<%
//Decoded data from charts.
String data="";
//Rows of color values.
String[] rows;
//Width and height of chart.
int width=0;
int height=0;
//Default background color of the chart
String bgcolor="";
Color bgColor;
//Get the width and height from form
try{
width = Integer.parseInt(request.getParameter("width"));
height = Integer.parseInt(request.getParameter("height"));
}
catch(Exception e){
//If the width and height have not been given, we cannot create the image.
out.print("Image width/height not provided.");
out.close();
}
if(width==0 || height==0){
//If the width and height are less than 1, we cannot create the image.
out.print("Image width/height not provided.");
out.close();
}
//Get background color from request and set default
bgcolor =request.getParameter("bgcolor");
if (bgcolor==null || bgcolor=="" || bgcolor==null){
bgcolor = "FFFFFF";
}
//Convert background color to color object
bgColor = new Color(Integer.parseInt(bgcolor,16));
//Get image data from request
data = request.getParameter("data");
if(data==null){
//If image data not provided.
out.print("Image Data not supplied.");
out.close();
}
try{
//Parse data
rows = new String[height+1];
rows = data.split(";");
//Bitmap to store the chart.
//Reference to graphics object - gr
BufferedImage chart = new BufferedImage(width,height,BufferedImage.TYPE_3BYTE_BGR);
Graphics gr = chart.createGraphics();
gr.setColor(bgColor);
gr.fillRect(0,0,width,height);
String c;
int r;
int ri = 0;
for (int i=0; i<rows.length; i++){
//Split individual pixels.
String[] pixels = rows[i].split(",");
//Set horizontal row index to 0
ri = 0;
for (int j=0; j<pixels.length; j++){
//Now, if it's not empty, we process it
//Split the color and repeat factor
String[] clrs = pixels[j].split("_");
//Reference to color
c = clrs[0];
r = Integer.parseInt(clrs[1]);
//If color is not empty (i.e. not background pixel)
if (c!=null && c.length()>0 && c!=""){
if (c.length()<6){
//If the hexadecimal code is less than 6 characters, pad with 0
StringBuffer str = new StringBuffer(c);
int strLength = str.length();
for ( int p = c.length()+1; p <= 6 ; p ++ ) {
str.insert( 0, "0" );
}
//Assing the new padded string
c = str.toString();
}
for (int k=1; k<=r; k++){
//Draw each pixel
gr.setColor(new Color(Integer.parseInt(c,16)));
gr.fillRect(ri, i,1,1);
//Increment horizontal row count
ri++;
}
}else{
//Just increment horizontal index
ri = ri + r;
}
}
}
//Returns the image
response.setContentType("image/jpeg");
response.addHeader("Content-Disposition", "attachment; filename=\"FusionCharts.jpg\"");
OutputStream os = response.getOutputStream();
ImageIO.write(chart, "jpeg", os);
os.close();
}catch(Exception e){
//IF the image data is mal-formatted.
out.print("Image data is not in proper format.");
out.close();
}
%>
|
Advertisement
| Hall of Fame |