Search results for 'thumbnail'. 2 post(s) found.
- 2009/06/03 How to resize image ?
- 2007/10/04 Creating thumbnail images
Here's the simple example can resizing source image:
<%@ page import="java.io.*,
java.awt.*,
java.awt.image.*,
javax.swing.*,
com.sun.image.codec.jpeg.*"
contentType="text/html;charset=MS949" %>
<%!
public static void createthumbnail(String soruce, String target, int targetW) throws Exception
{
Image imgSource = new ImageIcon(soruce).getImage();
int oldW = imgSource.getWidth(null);
int oldH = imgSource.getHeight(null);
int newW = targetW;
int newH = (targetW * oldH) / oldW;
Image imgTarget = imgSource.getScaledInstance(newW, newH, Image.SCALE_SMOOTH);
int pixels[] = new int[newW * newH];
PixelGrabber pg = new PixelGrabber(imgTarget, 0, 0, newW, newH, pixels, 0, newW);
pg.grabPixels();
BufferedImage bi = new BufferedImage(newW, newH, BufferedImage.TYPE_INT_RGB);
bi.setRGB(0, 0, newW, newH, pixels, 0, newW);
FileOutputStream fos = new FileOutputStream(target);
JPEGImageEncoder jpeg = JPEGCodec.createJPEGEncoder(fos);
JPEGEncodeParam jep = jpeg.getDefaultJPEGEncodeParam(bi);
jep.setQuality(1, false);
jpeg.encode(bi, jep);
fos.close();
}
%>
<%
createthumbnail("c:/inetpub/c/big.jpg","c:/inetpub/c/big_result.jpg",320);
%>
Another posts included in "JSP"
| How to set and get sessions on JSP code ? (0) | 2008/10/27 |
| How to add a declaration on JSP code ? (0) | 2008/10/27 |
| How to include file in JSP ? (0) | 2008/10/27 |
| How to print out text strings on HTML directly ? (0) | 2008/10/27 |
| Put Date Time on HTML (0) | 2008/10/27 |
Trackback : Cannot send a trackbact to this post.
Suppose you have a Web Form where uploading of files is enabled, using the HtmlInputFile HTML control, and a user is uploading an image. If you accept only images of a specified size, you might need to shrink the uploaded image / create a thumnail.
Here's how to create thumbnail images in ASP.NET Delphi web applications.
var
g : System.Drawing.Image;
thumbSize : Size;
imgOutput : Bitmap;
imgStream : MemoryStream;
begin
//This function creates the thumbnail image and returns the
//image created in Byte() format
g := System.Drawing.Image.FromStream(ImageStream) ;
thumbSize := NewThumbSize(g.Width, g.Height, tWidth, tHeight) ;
imgOutput := Bitmap.Create(g, thumbSize.Width, thumbSize.Height) ;
imgStream := MemoryStream.Create;
imgOutput.Save(imgStream, g.RawFormat) ;
imgOutput.Save(Path.Combine('c:\LocationOnServer',FileName)) ;
g.Dispose;
imgOutput.Dispose;
end;
function NewThumbSize(const currentwidth, currentheight, newWidth, newHeight : Double) : Size;
var
tempMultiplier : Double;
NewSize : Size;
begin
if currentheight > currentwidth Then
tempMultiplier := newHeight / currentheight
else
tempMultiplier := newWidth / currentwidth;
NewSize := Size.Create(Convert.ToInt32(currentwidth * tempMultiplier), Convert.ToInt32(currentheight * tempMultiplier)) ;
Result := NewSize;
end;
//Usage:
Generatethumbnail('ThumbnameOnServer', ImageFile.PostedFile.InputStream, thumbWidth, thumbHeight) ;
//Where
//ImageFile : System.Web.UI.HtmlControls.HtmlInputFile;
Another posts included in "Delphi"
| How to encrypt a string (0) | 2007/10/04 |
| Delphi for .Net Code Folding keyboard shortcuts (0) | 2007/10/04 |
| Implementing C#'s foreach loop in Delphi 8 (0) | 2007/10/04 |
| Technology sharing related with software development. Specially content... (0) | 2007/10/02 |
| Window flashing (0) | 2007/09/25 |
| How to use TTF Font Without Installing (0) | 2007/09/25 |
| How to show window contents while dragging (0) | 2007/09/25 |
| How to save text from Clipboard to a file (0) | 2007/09/25 |
Trackback : Cannot send a trackbact to this post.
-
Subject Buy xanax with no prescription.
2009/02/13 22:34
Buy 180 xanax. Xanax. No prescription xanax. Xanax cocktail. Buy cheap xanax without prescription. Side effects of xanax.
-
Subject Fetish town free scat porn and fetish sex sites.
2009/03/31 14:17
Scat porn archive cringe humor forum. Scat porn. Porn movie scat sex. Scat porn galleries.
-
Subject Free zoo porn movies.
2009/03/31 17:59
Animal sex zoo free porn bestiality horse.
-
Subject different money making ideas
2010/01/28 23:26
moneyideas
-
Subject different money making ideas
2010/01/29 07:43
moneyideas
-
Subject different money making ideas
2010/01/31 16:41
moneyideas

Prev

Rss Feed