java - Color Conversion RGB to HSV using formula -
java - Color Conversion RGB to HSV using formula -
i asked write programme based on java convert colors rgb hsv , not allowed utilize java.awt.color, far efforts got me level, don't know how create console read other methods reads main method..
public class colorconversion { public static void main(string[] args) { system.out.println("nope"); } void rgbtohsv( float r, float g, float b, float h, float s, float v ) { r=input.readfloat(); float min, max, delta; min = min( r, g, b ); max = max( r, g, b ); v = max; // v delta = max - min; if( max != 0 ) s = delta / max; // s else { // r = g = b = 0 // s = 0, v undefined s = 0; h = -1; return; } if( r == max ) h = ( g - b ) / delta; // between yellowish & magenta else if( g == max ) h = 2 + ( b - r ) / delta; // between cyan & yellowish else h = 4 + ( r - g ) / delta; // between magenta & cyan h = 60; // degrees if( h < 0 ) h += 360; } void hsvtorgb( float r, float g, float b, float h, float s, float v ) { int i; float f, p, q, t; if( s == 0 ) { // achromatic (grey) r = g = b = v; return; } h /= 60; // sector 0 5 = floor( h ); f = h - i; // factorial part of h p = v * ( 1 - s ); q = v * ( 1 - s * f ); t = v * ( 1 - s * ( 1 - f ) ); switch( ) { case 0: r = v; g = t; b = p; break; case 1: r = q; g = v; b = p; break; case 2: r = p; g = v; b = t; break; case 3: r = p; g = q; b = v; break; case 4: r = t; g = p; b = v; break; default: // case 5: r = v; g = p; b = q; break; } } private static float max(float r, float g, float b) { // todo auto-generated method stub homecoming 0; } private static float min(float r, float g, float b) { // todo auto-generated method stub homecoming 0; } private static int floor(float h) { // todo auto-generated method stub homecoming 0; } }
you declaring methods within main
:
class classname { public static void main(string[] args) { void methodinsidemain() { } } }
methods cannot within other methods in java. move methods out:
class classname { public static void main(string[] args) { } static void methodoutsidemain() { } }
in code, have shown it, rgbtohsv
, hsvtorgb
methods declared within main
. there no other compilation errors.
java
Comments
Post a Comment