Convert Color Image To Grayscale And Then To Sepia
Sep 15, 2014
I have the program working where the image is converted to grayscale but I get the following error when trying to convert from grayscale to sepia.
java:36 error: '. class' expected
red = Math.min(int(red * 1.08), 255);
java:36 error: illegal start of expression
red = Math.min(int(red * 1.08), 255);
import images.APImage;
import images.Pixel;
[Code] ....
View Replies
ADVERTISEMENT
Feb 28, 2014
[ATTACH=CONFIG]27j.jpg49[/ATTACH]Hello,
I'm having the hardest time getting a program to compile. I'm beginning to think I've downloaded the incorrect version of turtle graphics. This symbol looks foreign and I'm unsure how to find a solution. I have fixed some of the errors since this last picture but I will write out my code. The program takes a photo and converts to gray scale then to sepia
import images.APImages;
import images.Pixel;
import java.util.Scanner;
public class sepia{
public static void main(String [] args){
[Code] ....
View Replies
View Related
Aug 3, 2014
I have a greyscale image with alpha. I also have a colour. I want to change that greyscale image to the colour specified, with black remaining black and white being the specified colour, and the different shades of grey between becoming the shade of the specified colour.I've got a couple of different thoughts about how to solve it myself, but I rather hope there's an easier way.
Solution one would be to use a BufferedImage and just use getRGB/setRGB excessively.The second solution would be to use the above and cache the result. Given that there can be up to 10 different colour schemes, and up to approx. 2000 different images, this can, in the end, become excessively memory-hogging (although the general case would likely be 3 colours and perhaps a hundred or two images). It would also mean I'd have to loop through all images whenever the user changes the colour.
Is there a magical third solution that can translate a greyscale image to colour on-the-fly that's fast enough to run hundreds of thousands of times per second? No code available since this is just in the thought process right now.
View Replies
View Related
Jul 14, 2014
I'm trying to draw an image in grayscale. This is my code:
Java Code:
public void paintComponent(Graphics g) {
super.paintComponent(g);
setOpaque(true);
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_BYTE_GRAY);
Graphics g1 = image.getGraphics();
g1.drawImage(CardData.CARD_ART[cardID], 0, 0, null);
g1.dispose();
setOpaque(false);
} mh_sh_highlight_all('java');
For some reason, nothing displays.
View Replies
View Related
Jan 20, 2015
I've been using Java Advanced Imaging to convert tiff images to jpeg. The code I'm using is pretty simple, and I'll include it below:
Java Code: private static void convertImage(File tiff_src, File jpg_dest)
{
if (tiff_src == null || !tiff_src.exists()) throw new IllegalArgumentException();
try
{
SeekableStream stream = null;
[code]...
The problem when I run this code is that during conversion, the decoder or encoder seems to drop a good deal of black. I'd like to include examples, but the tiff images are about 30 MB...I've tried configuring the decode parameters, as well as the encode parameters, but like I said, somewhere during conversion I drop a good deal of the black from the image.
View Replies
View Related
Jul 21, 2014
I am trying to custom graphic class..,My task is to replace the specific area color of the image when i select the area & pick the color..,If i choose the hand / body of the T-shirts means the color can change by the user..,
View Replies
View Related
Feb 12, 2014
How can I write a BufferredImage to an 8-bit .bmp using indexed colors stored in a <String,Color> Hashtable?
I've never used Hashtables before, and I didn't know color indexing existed until now, but I can do most other things in java fairly well.
I'm not looking for code, just the concept, as I really don't know how Hashtables work (although I could figure it out), and how color indexing does. I know how to write image files, just not indexed or with a specific number of bits. I am using Hashtables generated from GIMP.
EDIT: I mainly want to know how to save a BufferedImage as an indexed .bmp.
View Replies
View Related
Oct 7, 2014
I am trying to create a virus simulation program. The program is supposed to just be a map of the world where the user can click any country in the world to specify where they want their virus to start, specify how transmittable the virus is, and be able to see how the virus spreads through the world by seeing a change in color throughout the world,
I want the world map to initially start out with a very light yellow, and as areas of the world slowly start to get more and more infected by the virus, I want those areas on the map to start changing to a very dark red (going from a light yellow, through shades of orange and red, to dark red).
So, the main idea of this is to have a program that displays an image where certain parts of the image will slowly change color during the runtime of the program. I obviously know how to change colors of certain parts of a window or even an image, but this is very very detailed and advanced but how to even start this.
View Replies
View Related
Jun 10, 2014
No problem setting background color for layouts, e.g. bdrPn.setBackground(new Background((new BackgroundFill(Color.BLACK, CornerRadii.EMPTY, Insets.EMPTY))));
But neither of the following are working for me, running JavaFX 8 on latest OS-X
scene = new Scene(bdrPn, winW, winH, Color.BLACK);
scene.setFill(Color.BLACK);
scene.setFill() worked fine for previous versions of JavaFX.
View Replies
View Related
Oct 20, 2014
I've just started working on a program and i'm already having difficulties with the program. I can't get the background color to change from the basic gray color. Maybe you can tell me what i'm doing wrong.
import javax.swing.JFrame;
import javax.swing.WindowConstants;
import java.awt.*;
import java.lang.Object;
import java.awt.Color;
public class FrameDemo{
public static void main(String args[]){
Toolkit toolkit = Toolkit.getDefaultToolkit ();
[Code]...
also if theres any way to shorten up what I have there, that would be great.
View Replies
View Related
Nov 24, 2009
If I want to read from file the word "red" And then the following is not the right way like in the code ,, How to set the Color name
File inputFile = new File ("C:\input.txt");
Scanner scan = new Scanner (inputFile);
String RedColor=scan.nextLine();
Color backColor = new Color(redColor);
View Replies
View Related
Jan 16, 2015
I am trying to align the core/middle side color of a cube, index 4, with the bottom middle color of the same side, index 7. (Each side has values 0-8 where 0 - is the top left corner, 1 is the top mid corner, 2 is the top right corner, 3 is the middle left corner, etc).
In addition to lining up those two colors, I am also making sure that the neighbor color of index 7(the color that it is attached), in this case the bottom color, matches with the top core/middle color. I will attach some pictures and a print out to show what I am talking about...
However, in my code when I am trying to align all of these up together, it does not go into the while loop. Each of the loops essentially is trying to get a match of same color with index 4 and 7, as well as making sure that index 7's neighbor color (the bottom color, in this case) matches with the top color.
Here is what I have tried:
private void alignSideColor(){//make the bottom colors neighbor match with a middle side value and rotate it to the top, for the top cross
if(cube.bottom.square[1].charAt(0) == topColor){
while(cube.front.square[7].charAt(0) != frontColor && cube.bottom.square[1].charAt(0) != topColor){
rotateBottomClockwise(1);
System.out.println("Trying to align side color...");
[Code] .....
The print out of the ELSE IF is:
alignment is: W-G and tops: R-R
NOW ITS ALIGNED
even though the sides, index 4 and 7, are NOT aligned with each other
I have also tried the same thing but with out the 2nd condition in each while loop, and although is DOES enter the while loop, it does not perform correctly -- index 4 and 7 WILL have matches colors, but it does not check to see if index 7's neighbor matches with the top color.
Here is how it prints out
** ** ** G7 B6 Y1 ** ** **//this portion is the back of the cube
** ** ** R6 W5 O4 ** ** **
** ** ** R3 W2 O1 ** ** **
B3 G4 Y9 W9 O8 Y7 W3 B4 G9//this portion is the left, top, and right of the cube
B2 G5 R8 W4 R5 Y6 O2 B5 G8
O7 W8 R9 B7 B8 B9 R1 R4 R7
** ** ** O3 O6 O9 ** ** **//this portion is the front of the cube
** ** ** Y2 Y5 Y8 ** ** **
** ** ** B1 G6 W7 ** ** **
** ** ** Y3 Y4 G1 ** ** **//this portion is the bottom the cube
** ** ** R2 O5 G2 ** ** **
** ** ** W1 W6 G3 ** ** **
Here is the cube showing the top, left and front side
Here is the left and bottom side. As you can see index 4, G5 -- yes that is a 5 lol -- does not have the same color as index 7, W8.
I need to rotate the bottom until W8 is aligned with a middle white value. An examples of a neighbor is: W8-R2
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
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
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
Mar 14, 2014
I've been using grid world with my school. It's a part of the eimacs textbook. the following code that I wrote for gridworld. It's a very small tad bit of code:
Actor actor = new Actor();
actor.putSelfInGrid( grid, new Location( 5, 3 ) );
public void setColor (Color RED);
I get the following error:
error: illegal start of expression
public void setColor (Color RED);
View Replies
View Related
Aug 22, 2014
I am stuck. I was trying to make my own Color to use with awt.
I used the statement :
public static final Color purple = new Color(255,0,255);
When I try to use Color.purple it says it cannot reference purple.
View Replies
View Related
May 27, 2014
I am working on a chat programme and I was wondering how to separate the both usernames for example:
Server is me , and Client is the first man who had connected to me , so I want to be
Server to be in green color , and Client to be in Red
Server(green):Hi
Client(red):hello
Server(green):How you doin'
Client(red):Fine
My second question is both of em' to have minutes and dates for example
27.05.2014 11:30pm Server(green):Hi
27.05.2014 11:31pmClient(red):hello
27.05.2014 11:32pmServer(green):How you doin'
27.05.2014 11:33pmClient(red):Fine
View Replies
View Related
Jan 17, 2014
I'm programming in school using Netbeans and we've just started with graphical programming (i.e JPanel, JClass, JFrame). This is my first assignment and the purpose of this program is that when you press the mouse you will fill 4 circles with diffrent colors. I've managed to draw 4 circles with diffrent colors but I want my cursor to change color simultaneously. Here's my code so far ....
//Java klass "Klick"
public class Klick {
//Medlemsvariabler.
private int x = 0;
private int y = 0;
private int r = 1;
public int antal = Rityta.antalKlick;
[Code]...
View Replies
View Related
Jan 29, 2015
Color only changes, when resizng frame with mouse, not when clicking.
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class SimpleGui1 implements ActionListener {
JFrame frame;
MyDrawnPanel drawnPanel;
[Code] .....
View Replies
View Related
Oct 10, 2014
I'm doing this project where I need to make a persian carpet using recursive methods. I already have my recursive what I'm trying to implement is the use of color. My method BorderColor draws a square using a random color choose from an array.
public void Cuadrado(Graphics g){
Random color = new Random();
g.setColor(colors[color.nextInt(colors.length)]);
g.drawLine(left, top, right, top);
g.drawLine(left, top, left, bottom);
[Code] ....
What I'm trying to do is getting the color from 4 different corners in order to create a new one and make a recursive call. I already tried using the method getPixelColor from the Robot() object but I quit it because is a recursive method and it may cause trouble with the recursive stack. I created this method to create the new color and then call it in the PersianRug method, but I dont have a clue on how to obtain and implement the new colors.
public int newColor(int c,int c1,int c2,int c3, int a){
int c4=((c+c1+c2+c3)%13)*a;
return c4;
}
View Replies
View Related
Apr 11, 2014
The title says it all and i'm a fairly new java programmer but here is the code:
package TestVersion;
import java.awt.Color;
import java.awt.Graphics;
[Code]......
I think i need a variable or something oh and here is the 2 other classes, the keylistener one:
package TestVersion;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
[Code].....
View Replies
View Related
Jan 6, 2015
how I can highlight one column with color? When i add color to a column the entire table is colored.
View Replies
View Related