473,769 Members | 2,077 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Image manipulation in applications

Hi.

I'm doing some image manipulation in an applet using the example code on
this page:
http://www.akop.org/art/pixels3.htm

However, I really want an application rather than an applet, I just
can't figure out how to do the image loading and manipulation when it's
not from inside an applet. Any hints on the subject are appreciated.

Thanks in advance,

Rune
--
http://runevision.com
Jul 17 '05 #1
4 5442
"Rune Johansen" <rune[insert_current_ year_here]@runevision.com > wrote in message news:<eN******* *************** @news000.worldo nline.dk>...
Hi.

I'm doing some image manipulation in an applet using the example code on
this page:
http://www.akop.org/art/pixels3.htm

However, I really want an application rather than an applet, I just
can't figure out how to do the image loading and manipulation when it's
not from inside an applet. Any hints on the subject are appreciated.

Thanks in advance,

Rune

If its java.awt.Compon ent or its descendants, write its paint()
method. Or if it's javax.swing.JCo mponents, write its paintComponent( )
method. These two methods take a Graphics object as their argument,
and the Graphics object can be readily casted into a Graphics2D
object. Those Graphics and Graphics2D objects have various drawing
methods including those that draw existing images on your component.

Examples abound on the net.
Jul 17 '05 #2
"Rune Johansen" <rune[insert_current_ year_here]@runevision.com > wrote in message > However, I really want an application rather than an applet, I just
can't figure out how to do the image loading and manipulation when it's
not from inside an applet. Any hints on the subject are appreciated.

Thanks in advance,

Rune


For loading and saving images, you have several options:

Use javax.imageio.I mageIO is the easiest way to load images. It
currently can only handle JPEG, GIF and PNG, but with Java1.5 should
be able to load TIFFs too. ImageIO.read() will read your images and
ImageIO.write() will write them.

The other main way to load images is through the Toolkit.
java.awt.Toolki t.getDefaultToo lkit().getImage (filename) will load any
GIF, JPEG or PNG.

If you used the first method to load your image, you'll have a
BufferedImage who's data you can access directly.

If you used the second method, you'll have an ordinary Image. You can
read it's data by creating an array to hold pixel data, then creating
PixelGrabber and calling grabPixels() to get the data. To turn your
data back into an image, you'll need to create a
java.awt.image. MemoryImageSour ce.

While the first method is much easier to use, the second method is, in
my experience, much faster. The second method is the 'classic' way to
manipulate images.

There is also a way to do all of this with the Java Media Framework,
but I've been unable to figure out how to use it. The docs for it
contain much information, but are nearly impossible to learn from.

Mark McKay
--
http://www.kitfox.com
Jul 17 '05 #3
sorry I put this in the wrong place

I managed to do this with ImageIO, example taken from:

http://www.geocities.com/marcoschmid...creenshot.html

watch out for the javascript errors, but good site with loads of image and
java stuff...

This was the code I used.

// temp output file bit
public void outputFile() throws Exception{
//start of the output stuff

FileOutputStrea m fo = new FileOutputStrea m("myImg.jpg" );//name of image

BufferedOutputS tream bo = new BufferedOutputS tream(fo);//set to buffered
stream

//destination here is the name of the raster reference. referencing a
bufferedImage
ImageIO.write(d estination, "jpeg", bo);//write the file out using ImageIO
to the HD

bo.close();
//end of the output stuff
}
// EOF temp outupt file bit

hope this helps

cheers
Martin

From: "Murray" <pa***@SPAMoffS PAMMER.optusSP4 Mnet.com.au>
Subject: Re: Saving a BufferedImage as a JPEG
Date: 07 May 2004 16:49
"Michael Johnston" <mi************ ****@saic.com> wrote in message
news:72******** *************** ***@posting.goo gle.com...
I am saving a BufferedImage as a JPEG file under Windows XP.
I am using the JAI JPEGImageEncode r class.
The JPEG is saved as CMYK but I need RGB.
I cannot figure out how to get RGB. Any help?
Where is the BufferedImage coming from? If you're creating the object
yourself, try using INT_RGB imageType instead of the default ARGB.

image = new BufferedImage(x , y, BufferedImage.T YPE_INT_RGB);

It might also be worth trying this:

JPEGImageEncode r encoder = JPEGCodec.creat eJPEGEncoder(os );
JPEGEncodeParam param = encoder.getDefa ultJPEGEncodePa ram(image);
encoder.encode( img, param);

--

---------------
http://www.nonstoploop.co.uk/ - dynamic websites
http://www.rossanobacchin.be/ - fine art
http://www.weycameras.co.uk/ - photographic supplies
---------------

"Rune Johansen" <rune[insert_current_ year_here]@runevision.com > wrote in
message news:eN******** **************@ news000.worldon line.dk... Hi.

I'm doing some image manipulation in an applet using the example code on
this page:
http://www.akop.org/art/pixels3.htm

However, I really want an application rather than an applet, I just
can't figure out how to do the image loading and manipulation when it's
not from inside an applet. Any hints on the subject are appreciated.

Thanks in advance,

Rune
--
http://runevision.com

Jul 17 '05 #4
what kind of app are you working on or is this some sort of extended
assignement ?

news.skynet.be wrote:
sorry I put this in the wrong place

I managed to do this with ImageIO, example taken from:

http://www.geocities.com/marcoschmid...creenshot.html

watch out for the javascript errors, but good site with loads of image and
java stuff...

This was the code I used.

// temp output file bit
public void outputFile() throws Exception{
//start of the output stuff

FileOutputStrea m fo = new FileOutputStrea m("myImg.jpg" );//name of image

BufferedOutputS tream bo = new BufferedOutputS tream(fo);//set to buffered
stream

//destination here is the name of the raster reference. referencing a
bufferedImage
ImageIO.write(d estination, "jpeg", bo);//write the file out using ImageIO
to the HD

bo.close();
//end of the output stuff
}
// EOF temp outupt file bit

hope this helps

cheers
Martin

From: "Murray" <pa***@SPAMoffS PAMMER.optusSP4 Mnet.com.au>
Subject: Re: Saving a BufferedImage as a JPEG
Date: 07 May 2004 16:49
"Michael Johnston" <mi************ ****@saic.com> wrote in message
news:72******** *************** ***@posting.goo gle.com...
I am saving a BufferedImage as a JPEG file under Windows XP.
I am using the JAI JPEGImageEncode r class.
The JPEG is saved as CMYK but I need RGB.
I cannot figure out how to get RGB. Any help?

Where is the BufferedImage coming from? If you're creating the object
yourself, try using INT_RGB imageType instead of the default ARGB.

image = new BufferedImage(x , y, BufferedImage.T YPE_INT_RGB);

It might also be worth trying this:

JPEGImageEncode r encoder = JPEGCodec.creat eJPEGEncoder(os );
JPEGEncodeParam param = encoder.getDefa ultJPEGEncodePa ram(image);
encoder.encode( img, param);



Jul 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
1780
by: Giggle Girl | last post by:
Overall Background: I am in charge of migrating an already-made Content Mangement System from ASP to PHP. I do not know PHP -- yet! I am trying to foresee potential issues, and here is one. Image Specific Background: The ASP version of the CMS uses a 3rd party component to accept the uploading of images, and then to resize them so that thumbnails are made (as well as the original image) for photo albums.
2
9897
by: | last post by:
Hello All, I am writing a web application that reads a bitmap from a file and outputing it to a HTTP response stream to return the image to the requesting client. The image file is a regular bitmap file (filename.bmp) I am experiencing some difficulties with writing a bitmap to a http response stream. I load the bitmap from a file. and i use the following snippet of code to write to HTTP response stream
9
2151
by: Job | last post by:
Hi, I would like to find out what ASP/ASP.net can do with image manipulation. Does ASP have built in functions (eg. after upload to server) to manipulate images, like rotate, scale, crop etc.? Or are 3rd party solutions needed to do this? I am a php/codfusion programmer and know nothing about asp, so I'm hoping somebody here can help me out.
15
5363
by: David Lozzi | last post by:
Howdy, I have a function that uploads an image and that works great. I love ..Nets built in upload, so much easier than 3rd party uploaders! Now I am making a public function that will take the path of the uploaded image, and resize it with the provided dimensions. My function is below. The current function is returning an error when run from the upload function: A generic error occurred in GDI+. Not sure what exactly that means. From what...
9
3378
by: zacariaz | last post by:
I dont know, and i dont much like javascript, however, i am told that the only way to do want i want to do, is with javascript, so here goes. zoom and cut is the only features i need. 1. the image that need manipulating is places on the server. dont need js for that ;-) 2. the client has the oppotunity to manipulate the image. cut and zoom. 3. the image i saved on the server.
10
3490
by: Pulzar | last post by:
Hi there, I want to show a simple image on a web page, and allow the viewer to select and change one of the colours used in the image, and immediately preview the result. I'd like to keep the image processing away from the server to make the colour selection/preview process quicker, and I also don't want to pre-generate all possible images as there are too many colours that can be selected. Does JS (or any JS libraries) provide image...
3
26760
by: jon | last post by:
Hello, I've had long standing code that runs in IE, that I'm testing with firefox unsuccessfully now. The problem seems to be that images that I dynamically create don't fire their onload event in firefox. The onload method I assign is never being called. Any ideas why firefox isn't calling this, or what I can do for a workaround? Below is approxiatemate code of what I'm doing...
8
2013
by: shotokan99 | last post by:
i have this situation. i have a query string: http://www.myquerystring.com?x=xxxxx what this url does is it will return or start downloading a .png file. what i wanted to do is trap this png file and manipuate the image like resizing, color...etc. how can i do this?
12
2968
by: laredotornado | last post by:
Hi, I'm using PHP 5. I was wondering given an image, a.jpg, how can I make an image that would look like you slid a white index card (which I have a file, white.jpg with the same dimensions as a.jpg) over a.jpg? Note that you'd be sliding the image from top to bottom or from left to right, but not both. Thanks, let me know if this makes sense ... it's a litlte hard to describe.
0
9589
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10215
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10049
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9996
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7410
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6674
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5307
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3964
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.