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.
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.
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..,
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.
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.
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){
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.
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.
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);
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
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.
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 .
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; }
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'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;
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; }