How to convert a Graphics object into a JPG image?
I have this simple question about how to make a Graphics object into a JPG file...
I just need the names of the classes or the packages ... I'll figure out the rest of the details...
Thanks...
Anyway this might come in handy
JPEGUtils.java
============
* Created on Jun 22, 2005 by @author Tom Jacobs
package tjacobs.jpeg;
import java.awt.Image;
import java.awt.image.BufferedImage;
import java.awt.image.RenderedImage;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import javax.imageio.ImageIO;
import com.sun.image.codec.jpeg.JPEGCodec;
import com.sun.image.codec.jpeg.JPEGEncodeParam;
import com.sun.image.codec.jpeg.JPEGImageDecoder;
import com.sun.image.codec.jpeg.JPEGImageEncoder;
* Utilities for saving JPEGs and GIFs
public class JPEGUtils {
private JPEGUtils() {
super();
public static void saveJPEG(BufferedImage thumbImage, File file, double compression) throws IOException {
BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(file));
saveJPEG(thumbImage, out, compression);
out.flush();
out.close();
public static void saveJPEG(BufferedImage thumbImage, OutputStream out, double compression) throws IOException {
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam(thumbImage);
compression = Math.max(0, Math.min(compression, 100));
param.setQuality((float)compression / 100.0f, false);
encoder.setJPEGEncodeParam(param);
encoder.encode(thumbImage);
public static BufferedImage getJPEG(InputStream in) throws IOException {
try {
JPEGImageDecoder decode = JPEGCodec.createJPEGDecoder(in);
BufferedImage im = decode.decodeAsBufferedImage();
return im;
} finally {
in.close();
public static BufferedImage getJPEG(File f) throws IOException {
InputStream in = new BufferedInputStream(new FileInputStream(f));
return getJPEG(in);
public static void saveGif(RenderedImage image, File f) throws IOException {
saveGif(image, new FileOutputStream(f));
public static void saveGif(RenderedImage image, OutputStream out) throws IOException {
// Last time I checked, the J2SE 1.4.2 shipped with readers for gif, jpeg and png, but writers only for jpeg and png. If you haven't downloaded the whole JAI, and you want a writer for gif (as well as readers and writers for several other formats) download:
// http://java.sun.com/products/java-media/jai/downloads/download-iio.html
ImageIO.write(image, "gif", out);
public static void main(String[] args) {
// TODO Auto-generated method stub
}
Similar Messages
-
Converting a pages document into a .jpg image for web
I am trying to convert a pages document into a .jpg image for uploading to idisk. When I drag to iphoto, then export, the image is really small even when I use the large size on the jpg photo export. Is there an easy way to do this..... I am trying to upload it to idisk then link it to craigslist.
Help! It worked a couple of months ago!
Thanks
JohnA better way (I think) is to export or Print your Pages document as a PDF & open that PDF in Preview. Use the selection tool to select the area you want. You can crop & save as .jpg, but I recommend going to the File menu in Preview & choosing New From Clipboard to make a new file. This is because some programs, Pages in particular, will always "see" the unselected area & paste the whole thing. I also suggest using .png rather than .jpg. .jpg is a "lossy" format, .png will be much clearer.
-
How to convert an int variable into String type
hi everybody
i want to know how to convert an interger variable into string variable
i have to implement a code which goes like this
Chioce ch;
for(int i=0;i<32;i++)
// here i need a code to convert the int variable i into a string variable
ch.add(String variable);
how do i convert that int variable i into a String type variable??
can anyone help me?Different methods:
int a;
string s=a+"";or
String.valueOf(int) is the better option because Int.toString() generated an intermediate object to get the endresult
Ema -
How to convert a PDF file into a full editable WORD file?
Hi,
I tried to convert a pdf file into word but it is not fully editable. I can edit the title from the main page and that's it. The rest of the word document is saved as image. I tried editing teh pdf file but that one is not working either.
Please help on how to convert a PDF file into a full editable WORD file.
Thank youNot all PDF files are created equal. When a PDF file is created with Adobe Tools it is usually "tagged" with information about the fonts the images, the layout etc... This way when the PDF is saved to a new format like PPT or DOC then the results are usually usable. However, if you have a PDF file that was not tagged for some reason then run the Accessibility tools on the PDF to acquire some basic tagging. This may get you a better result. Also if you have a PDF that is an image, then you may want to run OCR on it.
-
How to convert my MM alias into an AppleID to use it with iCloud?
I used MobileMe and created a mail that became my Apple ID. Then I created an alias that became my main e-mail so now with iCloud I wish that aslias could become my Apple ID. I don't care to loose the first Apple ID but "How to convert my MM alias into an AppleID to use it with iCloud?"
You cannot convert an alias to Apple ID.
You can transfer your MM to iCloud with your main Apple ID.
There will be your alias as well.
Regards -
How to convert an NWDI project into a Local project?
Hi Experts,
Please tell me " how to convert an NWDI project into a Local project? "
If you cHi Srini
1. Copy/Paste Webdynpro components in the new project as was suggested before
2. Or create new project, copy _comp folder from old project to the new one. But, do not forget to update .dcdef & .project files manually after this. You have to set the correct project name in .dcdef and set the correct local project path in .project.
BR, Sergei -
How to Convert Oracle Apps Report into XML Publisher
Hi
How to Convert Oracle Apps Report into XML Publisher?
ThanksIn Brief :
Re: XML Publisher
In Details :
http://www.oracle.com/technology/products/xml-publisher/docs/XMLEBSRep.pdf -
How to convert data from rows into columns
Hi,
I have a sql table and the data looks like this
GLYEAR GLMN01 GLMN02 GLMN03 GLMN04
2007 -109712.40 6909.15 4758.72 56.88
2007 -13411.32 19132.9 -5585.07 4362.64
Where GLyear reprsents Year and GLMN01 is February, GLMN02 is March and so on,
Now i want my output to be something like this which i want to insert into another table
GLYear GLMonth GLAmount
2007 February -109712.40
2007 March 6909.15
2007 April 56.88
My new table has 3 columns, GLYear,GLMonth,GLAmount.
Can someone please help me with the select statement on how to do this, i can work with the inserts.
Thanks.I want you to check these form tread they have the same discussion as you. They will definitely solve your problem
http://blog.jontav.com/post/8344518585/convert-rows-to-columns-columns-to-rows-in-sql-server
http://dba.stackexchange.com/questions/19057/convert-rows-to-columns-using-pivot-in-sql-server-when-columns-are-string-data
http://stackoverflow.com/questions/18612326/how-to-convert-multiple-row-data-into-column-data-in-sql-server
I hope this helps you in solving your problem.
Please remember to click “Mark as Answer” on the post that has answered your question as it is very relevant to other community members dealing with same problem in seeking the right answer -
API for converting a Java object into XML?
Do you know of any Java API that I could use to convert a Java
object into its equivalent XML representation?
For example if I have a class called "Foo" with variables va, vb
and I have an instance of Foo with va having the value 1 and vb
having the value 2, I would like be able to generate the
following XML fragment:
<Foo>
<va>1</va>
<vb>2</vb>
</Foo>
Thanks,
-- Rob
nullRob Tan (guest) wrote:
: Do you know of any Java API that I could use to convert a Java
: object into its equivalent XML representation?
: For example if I have a class called "Foo" with variables va,
vb
: and I have an instance of Foo with va having the value 1 and
vb
: having the value 2, I would like be able to generate the
: following XML fragment:
: <Foo>
: <va>1</va>
: <vb>2</vb>
: </Foo>
: Thanks,
: -- Rob
There is none that I know of.
Oracle XML Team
http://technet.oracle.com
Oracle Technology Network
null -
Hi...
2.....how to convert normal function module into remote enabled function module?
thanks and regards,
k.swaminath.Hi,
In the attributes tab select radio button as remote enabled instead of normal..
u can call the remote enabled fm as...
CALL FUNCTION <Function module> destination <destination name>
Regards,
Nagaraj -
i can't find this anywhere... how to convert mp3 (not music) into text without spending much $$$.
function(){return A.apply(null,[this].concat($A(arguments)))}
hope1hope2 wrote:
i can't find this anywhere... how to convert mp3 (not music) into text without spending much $$$.
It's very unlikely that you'l
l find any help here; this forum is used only
for testing purposes. Unfortunately, I cannot suggest
another forum
Extra line breaks kindly supplied by the software. -
How to convert trailing minus sign into the leading minus sign
Hi
Can any plz tell me How to convert trailing minus sign into the leading minus sign? I mean in PI the amount filed shows like 150.00- i want to convert that into -150.00.
Thanks
GovindaHi Shabarish,
The code works but what if the input is something like [ 10.000-] i.e. with some spaces before 10.000- and the output as per your code comes as [- 10.000]. How do we tackle such cases if there is inconsistency in data i.e. some values come as [ 10.000-] i.e. spaces before the number and some values as [12.000-].
The output of this will come as
[- 10.000]
[-12.000]
How to make it as
[-10.000]
[-12.000]
Regards,
Shaibayan -
How to convert a word document into the PDF format?
Please instruct me step by step on how to convert several Word documents into the PDF format?
If properly installed and updated (depending on the WORD version), you can simply do any of the following:
1. Open the doc in WORD and select Print, choose the Adobe PDF printer, print.
2. Open the doc in WORD and go to the Acrobat menu in WORD and select create PDF (this uses PDF Maker).
3. Open the doc in Acrobat and the conversion should be done based on PDF Maker. -
How to convert a protected document into a PDF?
Hello,
I need to develop a plugin that needs to convert a protected document in office format into a pdf. I looked into the sdk and found the method AVConversionConvertToPDFWithHandler (). But can this method also apply the digital rigths of the protected document to the newly created pdf?
Is there any other way to convert a protected document into a pdf and at the same time apply the rights to the pdf? I don't want to use Adobe LiveCycle for digital rights management.
What are the requirements to develop a DRM plugin for acrobat?
Please Help!
Thanks in advance!The AVConversion APIs will use Office itself to perform the conversion (well, the rendering part). I would ASSUME that when Office opens the document, it will ask for any necessary passwords or other information to determine if the user has the rights to view and/or process the content of the document. If they do, then the conversion will succeed otherwise it will fail. The PDF will not have any DRM applied to it, since we don't know anything about the Office DRM options.
If you wish to apply DRM to the PDF, you will need to do that yourself or using tools such as LiveCycle Rights Management.
From: Adobe Forums <[email protected]<mailto:[email protected]>>
Reply-To: "[email protected]<mailto:[email protected]>" <[email protected]<mailto:[email protected]>>
Date: Tue, 29 Nov 2011 02:26:37 -0800
To: Leonard Rosenthol <[email protected]<mailto:[email protected]>>
Subject: How to convert a protected document into a PDF?
How to convert a protected document into a PDF?
created by poortip87<http://forums.adobe.com/people/poortip87> in Acrobat SDK - View the full discussion<http://forums.adobe.com/message/4051919#4051919 -
How to Convert a Planned Event into Firmly Booked Event
Dear All,
How to convert a planned event into firmly booked event?
Warm Regards
Vinod KumarCreated Template in active status.
Maybe you are looking for
-
Old version of iTunes on laptop won't transfer music to my new iPhone.
-
How can i modify this code in BI?
hi friends, suppose i have data in infosource with deffirent customers. like from usa,germany,uk. i created 3 cubes and uploaded records corresponding countries. i have written code like this in 3.5 loop at data_package. if data_package-/bic/zcustome
-
Problem Migrating to Bt Infinty from Zen Fibre lit...
Received Mac code from Zen 30/1/13 and passed to BT with my order 4/2/13. Broadband activated as estimate 11/2/13 and continued until 14/2/13. On 15/2/13 reported loss of internet access as fault. Eventually BT advised that the order was cancelled as
-
WIS 10006 error: object does not exist in report...
Hello All, I've been having trouble with this particular formula that i'm using as a variable for parent-child report linking: ="<a href=\"../../opendoc/openDocument.jsp?iDocID=AVMeLBMmFrdJkNpCFp33vjs&sDocName=Open+Incident+Details+Report+-+Owning+Gr
-
How to convert MiniDiscs into iTunes as tracks/albums?
Hi there, from the earlier days of Sony's MiniDisc era I have a big collection of MiniDics around with all kinds of recordings (CD's, radio takes, interviews etc). I still have a MD Walkman (Sony MZ-R30) and am using a iMac 27" and a MacBookPro 17" (