Image Print In Poor Quality With Jagged Edges
Apr 14, 2014
I'm trying to print (to the printer) a small image 265x35 px and it is printed in very poor quality with jagged edges. When I'm printing it from any other program (e.g. Word, mspaint, etc) it is printed clearly.
Also, the image is printed bigger than it's normal size (approximately 25%). But, I'm not doing any scale in my code. I did scaled it down to the right size, but the quality still remained very poor and jadged.
The image is a transparent PNG file. I tried with a BMP too, but I got the same results.
I'm using
Graphics g;
g.drawImage(headerLogo, x, y, headerLogo.getWidth(), headerLogo.getHeight(), imageObserver);
View Replies
ADVERTISEMENT
Oct 12, 2014
Write a Java program that reads a positive, non-zero integer as input and checks if the integer is deficient, perfect, or abundant.A positive, non-zero integer, N, is said to be perfect if the sum of its positive proper divisors (i.e., the positive integers, other than N itself, that divide N exactly) is equal to the number itself. If this sum is less than N, the number is said to be deficient. If the sum is greater than N, the number is said to be abundant.
For example, the number 6 is perfect, since 6 = 1 + 2 + 3, the number 8 is deficient, since 8 > 1 + 2 + 4, while the number 12 is abundant, since 12 < 1 + 2 + 3 + 4 + 6.
Sample Output:
Input N: 5
5 is deficient.
Input N: 6
6 is perfect.
Input N: 18
18 is abundant.
View Replies
View Related
Jul 10, 2013
I write lot of java code everyday. Sometime in hurry I forget to close the resources (connection,file,etc,) in JAVA6 and this causes memory leak issues. I am looking for an eclipse plugin which can complain for these minor mistakes. Also I am looking for some more eclipse plugins which can improve my source code quality like naming conventions, code redundancy, complexity, too long code outside methods, etc,.
View Replies
View Related
Aug 23, 2014
I am simply trying to print out a deck of 54 playing cards. i have organized them in to two separate arrays the first array to place all the image icons the second array to hold the 54 Jlabels. I think my problem lies in the setLayout portion of the program . I also think my image icon path may be wrong?
import javax.swing.*;
import java.awt.*;
public class CardIconArray extends JFrame {
private static final long serialVersionUID = 1L;
final public static int numberofcards=54;
CardIconArray(){
[Code] ....
View Replies
View Related
Apr 8, 2014
So I have scale, and you can change it, like I print out a bufferedimage read by imageio from a file, can I enlarge it by 2x, because my tiles are too small eventhough they're 16x16, should I decided to decrease my tile grid from 40 to 20, but instead change the scale by 2. Can I enlarge the image as it is put on the screen?
View Replies
View Related
Jan 9, 2015
I am trying to make a letter bounce off of the edges of the frame, but im stuck .
Java Code:
import javax.swing.*;
import java.awt.*;
public class MainProgram extends JFrame{
public static void main(String[] args) {
// TODO Auto-generated method stub
MainProgram frm = new MainProgram();
frm.setTitle("Moving a letter");
[Code] ....
View Replies
View Related
Jan 30, 2015
How to create histogram in JavaFX ? Is it possible to do it using BarChart? how to label the bin edges (ticks)?
View Replies
View Related
Jan 28, 2015
How can I do this: program to compare two files that which has data like node id: which it is connected to. like 3: 5 7 12 5: 7 14 9 etc. so this type of content is there in both the files. I need to compare these two files and count new edges for each node and also total new edges.
How can I do this? I tried and learnt taking files as input and read the normal text content.
This is what I tried :
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package comparetwofiles;
import java.io.*;
import java.util.*;
[Code]...
View Replies
View Related
Oct 6, 2014
I'm writing a program to print an ASCII image using nested for loops. The output is a rocket ship that looks like this.
/**
//**
///**
////**\
/////**\
+=*=*=*=*=*=*+
|../..../..|
|.//..//.|
|//////|
|//////|
|.//..//.|
|../..../..|
+=*=*=*=*=*=*+
|//////|
|.//..//.|
|../..../..|
|../..../..|
|.//..//.|
|//////|
+=*=*=*=*=*=*+
/**
//**
///**
////**\
/////**\
I'm having problems with the mid section of the rocket, specifically the bottom part of the mid section:
|../..../..|
|.//..//.|
|//////|
I'm having difficulty writing the for loop to correctly print the dots. You're supposed to incorporate a constant which allows you to adjust the size of the overall figure. The loop doesn't work when I adjust the size, only when the value of HEIGHT is 3. The loop, however, for some reason works with the top part of the mid section.
This is the for loop for the top section.
for (int dots = 1; dots <= -1 * line + 1 * HEIGHT; dots++) {
System.out.print(".");
}
This is the for loop for the bottom section.
for (int dots = -1 * line + 1 * HEIGHT; dots <= 1; dots++) {
System.out.print(".");
}
Usually reversing the iteration of the loop just requires flipping the conditions, right? But it didn't work this time for some reason. Why this doesn't work? I can post the code to my entire program for compiling.
View Replies
View Related
Nov 21, 2014
I wrote this code which print a black image depends on the number of rows and columns you give it
public class BlackImg {
private Mycolor[][] colorArr; //Mycolor is a class i wrote that represents colors.
// no need for showing the class here.
// so i created here an array of type Mycolor, for example:
// { {(255,255,255), {(127,127,0)} }
[Code] .....
my problem is that my output comes good except the last line ,
Output:
(0,0,0) (0,0,0) (0,0,0) (0,0,0)
(0,0,0) (0,0,0) (0,0,0) (0,0,0)
(0,0,0) (0,0,0) (0,0,0) (0,0,0)
BlackImg@1db9742 //what is this line , why does it showing up ?
View Replies
View Related
Apr 7, 2014
Sir, I'am new to Swing Programming. I have to create an application where an image is displayed on one Label. The same image has to be split in parts and stored in database pert wise. Later the user has to retrieve the entire image by viewing a small part of the image. I have already displayed the full image on the Label, now i don't know how to split the image and store it part wise in the database.
View Replies
View Related
Jan 5, 2015
I stored an image into MySQL database using swings and hibernate but I am struggling to retrieve that image from MySQL database and display same image in the jTable cell and same as on jLabel whatever I retrieve from the database using swings and hibernate .
View Replies
View Related
Dec 24, 2014
I had string url for image in mysql database and I want show image in mu jsp file bu I can't.
<c:forEach var="urun" items="${listUrun.rows}">
<tr>
<td><c:out value="${urun.kitapresim}" /></td>
<img src="<c:url value="${urun.kitapresim}" /> " width="270" height="190"/>
URL...
View Replies
View Related
Apr 12, 2014
Basically the class is supposed to have a static variable that keeps track of the number of companies (numberOfCompanies) that have been created and a static method that returns the value of this variable. I need to have a constructor and a method to addEmployee, a method to printCompany, and a toString method. The addEmployee method will check that there is only 1 salesperson, 2 designers, and 4 manufacturing persons at a time and will check that there are no more than 7 employees of the company.
The addEmployee method will return a String indicating what the error is (i.e. "There is already a sales person in this company") or a null if the employee was added. If attempting to name a third company, an error message will be shown. what i have so far but my print company mmethod returns null company class :in which i am obliged to use inputdialog because it says that it cannot return void when i use the showmeassage diaolog.
company class:
import java.util.ArrayList;
import javax.swing.JOptionPane;
public class Company {
private ArrayList<Employees> list ;
private static int numberOfCompanies;
[Code] ....
error message when print button is clicked:
Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException: JOptionPane: parentComponent does not have a valid parent
at javax.swing.JOptionPane.createInternalFrame(Unknown Source)
at javax.swing.JOptionPane.showInternalOptionDialog(Unknown Source)
at javax.swing.JOptionPane.showInternalMessageDialog(Unknown Source)
[Code] ......
View Replies
View Related
Feb 23, 2014
I successfully added a background image on the Panel but I can't create my JButton image on top of my background image.
ImageIcon piano = new ImageIcon("src/img/piano_backgrd.png");
JLabel backlabel = new JLabel(piano);
panel.add(backlabel, new Integer(Integer.MIN_VALUE));
backlabel.setBounds(0, 0, piano.getIconWidth(), piano.getIconHeight());
JButton volup = new JButton(new ImageIcon("src/img/volup.png"));
volup.setLocation(10, 0);
panel.add(volup);
View Replies
View Related
Jul 25, 2014
I want to create two thread one thread will print odd number and another thread will print even number. but the number should be in a sequence like
1 2 3 4 5 6 7 8 9 10
View Replies
View Related
Nov 21, 2014
I'm trying to make a method that takes an image and turns it into a tile image. So if the original image looks like this:
[URL] ....
then the output image should look like this:
[URL] ....
Here's a method that's supposed to do that but for some reason the output image looks the same as the original:
public static int[][] tile(int[][] arr){
int[][] tile = new int[arr.length][arr[0].length];
for (int i = 0; i < arr.length; i++) {
tile[i]=arr[i];
}
return tile;
}
I recently changed the method and the error message I'm getting is "bad operand types for binary operator '+'. Here's the method:
public static int[][] tile(int[][] arr){
int[][] tile = new int[arr.length][arr[0].length];
for (int i = 0; i < arr.length; i++) {
for(int j=0; j<arr[i].length;j++){
tile[j]=(tile[j])+(arr[i]);
}
}
return tile;
}
View Replies
View Related
Mar 3, 2014
how to hide an image in another image in java
By using Steganography we can hide text in an image. But how it works for image.
View Replies
View Related
Jan 27, 2015
I'm trying to add an image icon to my application but since the code will be checked by another computer, I cannot use an image in my computer and use its file address. If I save the image in the project, is there a way to get the file address of the source code? Or is there a better way to add a unique image icon to the app?
View Replies
View Related
Mar 18, 2015
how do i add image in JPanel
View Replies
View Related
Jan 16, 2014
I have two classes. One is a game, and the other is a frame that displays an image. They are both on JFrames. I want to put the image onto my class that is a game, and I tried just putting the part that makes the image in the image class, but it will not let me use the JFrame from my other class, saying that it doesn't exist. How do I make them recognize each other? Here is my code
Game:
import java.awt.BorderLayout;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JPanel;
import java.awt.Color;
[code]....
View Replies
View Related
Feb 10, 2014
Read text from an image like jpg,png etc...
View Replies
View Related
Jul 28, 2014
Code of file:
Java Code: import javax.swing.JFrame;
import javax.swing.JLabel;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.imageio.ImageIO;
import javax.swing.JPanel;
[code]...
The serializable class ImagePanel does not declare a static final serialVersionUID field of type long public class ImagePanel extends JPanel{ ^^^^^^^ ^ ^^2 problems (1 error, 1 warning) mh_sh_highlight_all('java');
im basically just trying to put the image inside the GUI and centre the text underneath it. Which is hard to believe since the text is above the image in the code .
View Replies
View Related
Jan 8, 2015
How can I find the DPI of an image? The following code tells me the size of the image in pixels which I want to convert to millimetres. When I have looked at conversions I can find - "mm = (pixels * 25.4) / dpi" but how do I find out the DPI?
public class NewMain {
/**
* @param args the command line arguments
* @throws java.io.IOException
*/
public static void main(String[] args) throws IOException {
String filename = null;
BufferedImage bimg = ImageIO.read(new File("testimage.jpg"));
int width = bimg.getWidth();
[Code]...
View Replies
View Related
Nov 30, 2014
I want to import an image to resize but not sure how to start of.Should I be using the "BufferedImage & ImageIO.read" method or the "paint(Graphics g) { Image img1 = Toolkit.getDefaultToolkit().getImage" method?
View Replies
View Related
Mar 4, 2014
Is this even possible? I would like to make it so I can drag drop an image into a textbox . . .
View Replies
View Related