473,387 Members | 1,624 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Java for ImageProcessing

18
Dear Sir/Madam,

I try to make a function for image processing using java, I have add a menu item "Add Icon" under the menu bar. The function should read a file Icon.gif and place the icon at the top left hand corner of the image.
The following code is what I tried to do ...

after checking the user whether to select 'add icon',
if (s == "Add Icon") {
mBufferedImage = processor.AddIcon(mBufferedImage);

}

then it will run the class AddIcon as below...

public BufferedImage AddIcon (BufferedImage inputImage) {
BufferedImage icon = null;
Graphics g = inputImage.getGraphics();
g.drawImage(icon, 0,0, null);
return mBufferedImage;
}

I am just a beginner for the java programming and hope that someone can teach me:
1.how to ask the user to input the second image to place at the corner and
2.how to amend the class AddIcon to make it really work.
Thanks a lot for your kindly help!
Feb 25 '08 #1
1 1447
BigDaddyLH
1,216 Expert 1GB
Dear Sir/Madam,

I try to make a function for image processing using java, I have add a menu item "Add Icon" under the menu bar. The function should read a file Icon.gif and place the icon at the top left hand corner of the image.
The following code is what I tried to do ...

after checking the user whether to select 'add icon',
if (s == "Add Icon") {
mBufferedImage = processor.AddIcon(mBufferedImage);

}

then it will run the class AddIcon as below...

public BufferedImage AddIcon (BufferedImage inputImage) {
BufferedImage icon = null;
Graphics g = inputImage.getGraphics();
g.drawImage(icon, 0,0, null);
return mBufferedImage;
}

I am just a beginner for the java programming and hope that someone can teach me:
1.how to ask the user to input the second image to place at the corner and
2.how to amend the class AddIcon to make it really work.
Thanks a lot for your kindly help!
If you are a beginner at programming, I wouldn't suggest jumping into Swing. Learn the basics first. For example, don't use == to compare strings, use equals:
Expand|Select|Wrap|Line Numbers
  1. if (s.equals("Add Icon"))
I'm also wondering why your AddIcon method both takes and returns a BufferedImage -- isn;t it going to be a reference to the same object?
Expand|Select|Wrap|Line Numbers
  1. mBufferedImage = processor.AddIcon(mBufferedImage);
As for your questions: how to ask the user to input a file: use JFileChooser:
http://java.sun.com/docs/books/tutor...lechooser.html
You second question "how to make it work?" is too vague to answer. Please be more specific.
Feb 25 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Michael | last post by:
Hello I am trying to write a Java-Program which converts a XML-file in a HTML. It should take the Transformation-file from the XML-file itself. Below find a possible XML-file: <?xml...
0
by: Ravi Tallury | last post by:
Hi We are having issues with our application, certain portions of it stop responding while the rest of the application is fine. I am attaching the Java Core dump. If someone can let me know what...
1
by: ptaz | last post by:
Hi I'm trying to run a web page but I get the following error. Ca anyone please tell me a solution to this. Thanks Ptaz HTTP Status 500 - type Exception report
11
by: DrUg13 | last post by:
In java, this seems so easy. You need a new object Object test = new Object() gives me exactly what I want. could someone please help me understand the different ways to do the same thing in...
0
by: Markus Wollny | last post by:
Hello! When I try to run ./configure --with-java, it complains that ant doesn't work. However ant is installed, as is the latest Java SDK 1.4.2 from sun, PATH and JAVA_HOME are set correctly; ...
0
by: mailkhurana | last post by:
Hii , I am trying to use a type 2 driver to connect to DB2 0n AIX 5 I have a small java test to class to establish a conneciton with the db .. I am NOT using WAS or any appserver When I try to...
1
by: David Van D | last post by:
Hi there, A few weeks until I begin my journey towards a degree in Computer Science at Canterbury University in New Zealand, Anyway the course tutors are going to be teaching us JAVA wth bluej...
0
oll3i
by: oll3i | last post by:
package library.common; import java.sql.ResultSet; public interface LibraryInterface { public ResultSet getBookByAuthor(String author); public ResultSet getBookByName(String name);
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

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.