Initial
This commit is contained in:
commit
f57a7ad2fc
83
build.xml
Normal file
83
build.xml
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!-- You may freely edit this file. See commented blocks below for -->
|
||||||
|
<!-- some examples of how to customize the build. -->
|
||||||
|
<!-- (If you delete it and reopen the project it will be recreated.) -->
|
||||||
|
<project name="HSVScreenSaver" default="jar" basedir=".">
|
||||||
|
<description>Builds, tests, and runs the project .</description>
|
||||||
|
<import file="nbproject/build-impl.xml"/>
|
||||||
|
<!--
|
||||||
|
|
||||||
|
There exist several targets which are by default empty and which can be
|
||||||
|
used for execution of your tasks. These targets are usually executed
|
||||||
|
before and after some main targets. They are:
|
||||||
|
|
||||||
|
pre-init: called before initialization of project properties
|
||||||
|
post-init: called after initialization of project properties
|
||||||
|
pre-preprocess: called before text preprocessing of sources
|
||||||
|
post-preprocess: called after text preprocessing of sources
|
||||||
|
pre-compile: called before source compilation
|
||||||
|
post-compile: called after source compilation
|
||||||
|
pre-obfuscate: called before obfuscation
|
||||||
|
post-obfuscate: called after obfuscation
|
||||||
|
pre-preverify: called before preverification
|
||||||
|
post-preverify: called after preverification
|
||||||
|
pre-jar: called before jar building
|
||||||
|
post-jar: called after jar building
|
||||||
|
pre-build: called before final distribution building
|
||||||
|
post-build: called after final distribution building
|
||||||
|
pre-clean: called before cleaning build products
|
||||||
|
post-clean: called after cleaning build products
|
||||||
|
|
||||||
|
Example of pluging a my-special-task after the compilation could look like
|
||||||
|
|
||||||
|
<target name="post-compile">
|
||||||
|
<my-special-task>
|
||||||
|
<fileset dir="${build.classes.dir}"/>
|
||||||
|
</my-special-task>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
For list of available properties check the imported
|
||||||
|
nbproject/build-impl.xml file.
|
||||||
|
|
||||||
|
Other way how to customize the build is by overriding existing main targets.
|
||||||
|
The target of interest are:
|
||||||
|
|
||||||
|
preprocess: preprocessing
|
||||||
|
extract-libs: extraction of libraries and resources
|
||||||
|
compile: compilation
|
||||||
|
create-jad: construction of jad and jar manifest source
|
||||||
|
obfuscate: obfuscation
|
||||||
|
preverify: preverification
|
||||||
|
jar: jar archive building
|
||||||
|
run: execution
|
||||||
|
debug: execution in debug mode
|
||||||
|
build: building of the final distribution
|
||||||
|
javadoc: javadoc generation
|
||||||
|
|
||||||
|
Example of overriding the target for project execution could look like
|
||||||
|
|
||||||
|
<target name="run" depends="init,jar">
|
||||||
|
<my-special-exec jadfile="${dist.dir}/${dist.jad}"/>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
Be careful about correct dependencies when overriding original target.
|
||||||
|
Again, for list of available properties which you can use check the target
|
||||||
|
you are overriding in nbproject/build-impl.xml file.
|
||||||
|
|
||||||
|
A special target for-all-configs can be used to run some specific targets for
|
||||||
|
all project configurations in a sequence. File nbproject/build-impl.xml
|
||||||
|
already contains some "for-all" targets:
|
||||||
|
|
||||||
|
jar-all
|
||||||
|
javadoc-all
|
||||||
|
clean-all
|
||||||
|
|
||||||
|
Example of definition of target iterating over all project configurations:
|
||||||
|
|
||||||
|
<target name="jar-all">
|
||||||
|
<property name="target.to.call" value="jar"/>
|
||||||
|
<antcall target="for-all-configs"/>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
-->
|
||||||
|
</project>
|
1368
nbproject/build-impl.xml
Normal file
1368
nbproject/build-impl.xml
Normal file
File diff suppressed because it is too large
Load Diff
8
nbproject/genfiles.properties
Normal file
8
nbproject/genfiles.properties
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
|
||||||
|
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
|
||||||
|
build.xml.data.CRC32=d7bda4a9
|
||||||
|
build.xml.script.CRC32=64f59723
|
||||||
|
build.xml.stylesheet.CRC32=03eab09b
|
||||||
|
nbproject/build-impl.xml.data.CRC32=d7bda4a9
|
||||||
|
nbproject/build-impl.xml.script.CRC32=d8c21329
|
||||||
|
nbproject/build-impl.xml.stylesheet.CRC32=a4fc63f1
|
7
nbproject/private/private.properties
Normal file
7
nbproject/private/private.properties
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
#Fri Feb 19 22:12:04 EET 2010
|
||||||
|
netbeans.user=C:\\Users\\aNNiMON\\.netbeans\\6.9m1
|
||||||
|
javadoc.preview=true
|
||||||
|
deployment.counter=23
|
||||||
|
config.active=
|
||||||
|
deployment.number=0.0.22
|
||||||
|
app-version.autoincrement=true
|
4
nbproject/private/private.xml
Normal file
4
nbproject/private/private.xml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
|
||||||
|
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/1"/>
|
||||||
|
</project-private>
|
140
nbproject/project.properties
Normal file
140
nbproject/project.properties
Normal file
@ -0,0 +1,140 @@
|
|||||||
|
abilities=MMAPI=1.1,SATSAJCRMI=1.0,SATSACRYPTO=1.0,JSR82=1.1,NOKIAUI=1.0,JSR226=1.0,MIDP=2.1,JSR229=1.1.0,SATSAAPDU=1.0,CLDC=1.1,JSR177=1.0,JSR179=1.0.1,J2MEWS=1.0,VSCL=2.1,WMA=2.0,JSR172=1.0,SEMC_EXT_JP8=1.0,ColorScreen,OBEX=1.0,NokiaUI=1.0,JSR238=1.0,JSR239=1.0,JSR211=1.0,JSR234=1.0,ScreenWidth=240,lib/semc_ext_jp8.jar=1.0,MascotV3=1.0,JSR75=1.0,JSR184=1.1,SATSAPKI=1.0,ScreenHeight=321,ScreenColorDepth=8,JSR180=1.0.1,J2MEXMLRPC=1.0,
|
||||||
|
all.configurations=\
|
||||||
|
application.args=
|
||||||
|
application.description=
|
||||||
|
application.description.detail=
|
||||||
|
application.name=
|
||||||
|
application.vendor=Vendor
|
||||||
|
build.classes.dir=${build.dir}/compiled
|
||||||
|
build.classes.excludes=**/*.java,**/*.form,**/*.class,**/.nbintdb,**/*.mvd,**/*.wsclient,**/*.vmd
|
||||||
|
build.dir=build/${config.active}
|
||||||
|
build.root.dir=build
|
||||||
|
debug.level=debug
|
||||||
|
deployment.copy.target=deploy
|
||||||
|
deployment.instance=default
|
||||||
|
deployment.jarurl=${dist.jar}
|
||||||
|
deployment.method=NONE
|
||||||
|
deployment.override.jarurl=false
|
||||||
|
dist.dir=dist/${config.active}
|
||||||
|
dist.jad=HSVScreenSaver.jad
|
||||||
|
dist.jar=HSVScreenSaver.jar
|
||||||
|
dist.javadoc.dir=${dist.dir}/doc
|
||||||
|
dist.root.dir=dist
|
||||||
|
extra.classpath=
|
||||||
|
filter.exclude.tests=false
|
||||||
|
filter.excludes=
|
||||||
|
filter.more.excludes=**/overview.html,**/package.html
|
||||||
|
filter.use.standard=true
|
||||||
|
jar.compress=true
|
||||||
|
javac.debug=true
|
||||||
|
javac.deprecation=false
|
||||||
|
javac.encoding=windows-1251
|
||||||
|
javac.optimize=false
|
||||||
|
javac.source=1.3
|
||||||
|
javac.target=1.3
|
||||||
|
javadoc.author=false
|
||||||
|
javadoc.encoding=
|
||||||
|
javadoc.noindex=false
|
||||||
|
javadoc.nonavbar=false
|
||||||
|
javadoc.notree=false
|
||||||
|
javadoc.private=false
|
||||||
|
javadoc.splitindex=true
|
||||||
|
javadoc.use=true
|
||||||
|
javadoc.version=false
|
||||||
|
javadoc.windowtitle=
|
||||||
|
libs.classpath=
|
||||||
|
main.class=
|
||||||
|
main.class.class=applet
|
||||||
|
manifest.apipermissions=
|
||||||
|
manifest.file=manifest.mf
|
||||||
|
manifest.jad=
|
||||||
|
manifest.manifest=
|
||||||
|
manifest.midlets=MIDlet-1: Main,/icon.png,Main\n
|
||||||
|
manifest.others=MIDlet-Vendor: aNNiMON\nSEMC-StandbyApplication: Y\nMIDlet-Name: HSVScreenSaver\nMIDlet-Version: 1.0\n
|
||||||
|
manifest.pushregistry=
|
||||||
|
name=HSVScreenSaver
|
||||||
|
no.dependencies=false
|
||||||
|
nokiaS80.application.icon=
|
||||||
|
nsicom.application.monitorhost=
|
||||||
|
nsicom.application.runremote=
|
||||||
|
nsicom.application.runverbose=
|
||||||
|
nsicom.remoteapp.location=\\My Documents\\NetBeans Applications
|
||||||
|
nsicom.remotevm.location=\\Windows\\creme\\bin\\CrEme.exe
|
||||||
|
obfuscated.classes.dir=${build.dir}/obfuscated
|
||||||
|
obfuscation.custom=
|
||||||
|
obfuscation.level=9
|
||||||
|
obfuscator.destjar=${build.dir}/obfuscated.jar
|
||||||
|
obfuscator.srcjar=${build.dir}/before-obfuscation.jar
|
||||||
|
platform.active=Sony_Ericsson_SDK_2_5_0_4_for_the_Java_TM__ME_Platform_Emulator_
|
||||||
|
platform.active.description=Sony Ericsson SDK 2.5.0.4 for the Java(TM) ME Platform(Emulator)
|
||||||
|
platform.apis=JSR234-1.0,SATSA-APDU-1.0,JSR211-1.0,JSR75-1.0,J2ME-WS-1.0,J2ME-XMLRPC-1.0,JSR82-1.1,SATSA-JCRMI-1.0,SATSA-CRYPTO-1.0,JSR239-1.0,JSR179-1.0.1,MascotV3-1.0,JSR184-1.1,JSR238-1.0,MMAPI-1.1,NokiaUI-1.0,JSR229-1.1.0,SATSA-PKI-1.0,JSR180-1.0.1,JSR226-1.0,JSR177-1.0,SEMC_EXT_JP8-1.0,VSCL-2.0,VSCL-2.1,WMA-2.0,lib/semc_ext_jp8.jar
|
||||||
|
platform.bootclasspath=${platform.home}/lib/mascotv3.jar:${platform.home}/lib/jsr226.jar:${platform.home}/lib/jsr256.jar:${platform.home}/lib/satsa-crypto.jar:${platform.home}/lib/jsr229.jar:${platform.home}/lib/jsr238.jar:${platform.home}/lib/j2me-xmlrpc.jar:${platform.home}/lib/jsr211.jar:${platform.home}/lib/vscl21.jar:${platform.home}/lib/satsa-jcrmi.jar:${platform.home}/lib/jsr082.jar:${platform.home}/lib/satsa-apdu.jar:${platform.home}/lib/jsr184.jar:${platform.home}/lib/nokiaext.jar:${platform.home}/lib/jsr239.jar:${platform.home}/lib/jsr75.jar:${platform.home}/lib/jsr179.jar:${platform.home}/lib/satsa-pki.jar:${platform.home}/lib/jsr180.jar:${platform.home}/lib/vscl.jar:${platform.home}/lib/mmapi.jar:${platform.home}/lib/j2me-ws.jar:${platform.home}/lib/wma20.jar:${platform.home}/lib/jsr234.jar:${platform.home}/lib/semc_ext_jp8.jar:${platform.home}/lib/cldcapi11.jar:${platform.home}/lib/midpapi20.jar
|
||||||
|
platform.configuration=CLDC-1.1
|
||||||
|
platform.device=SonyEricsson_JP8_240x320_Emu
|
||||||
|
platform.fat.jar=true
|
||||||
|
platform.profile=MIDP-2.0
|
||||||
|
platform.trigger=CLDC
|
||||||
|
platform.type=UEI-1.0.1
|
||||||
|
preprocessed.dir=${build.dir}/preprocessed
|
||||||
|
preverify.classes.dir=${build.dir}/preverified
|
||||||
|
preverify.sources.dir=${build.dir}/preverifysrc
|
||||||
|
resources.dir=resources
|
||||||
|
ricoh.application.email=
|
||||||
|
ricoh.application.fax=
|
||||||
|
ricoh.application.icon=
|
||||||
|
ricoh.application.target-jar=
|
||||||
|
ricoh.application.telephone=
|
||||||
|
ricoh.application.uid=58974906
|
||||||
|
ricoh.application.version=
|
||||||
|
ricoh.dalp.application-desc.auto-run=false
|
||||||
|
ricoh.dalp.application-desc.energy-save=
|
||||||
|
ricoh.dalp.application-desc.exec-auth=
|
||||||
|
ricoh.dalp.application-desc.visible=true
|
||||||
|
ricoh.dalp.argument=
|
||||||
|
ricoh.dalp.codebase=
|
||||||
|
ricoh.dalp.display-mode.color=true
|
||||||
|
ricoh.dalp.display-mode.is-4line-support=false
|
||||||
|
ricoh.dalp.display-mode.is-hvga-support=true
|
||||||
|
ricoh.dalp.display-mode.is-vga-support=false
|
||||||
|
ricoh.dalp.display-mode.is-wvga-support=false
|
||||||
|
ricoh.dalp.information.abbreviation=
|
||||||
|
ricoh.dalp.information.icon.basepath=
|
||||||
|
ricoh.dalp.information.icon.location=
|
||||||
|
ricoh.dalp.information.is-icon-used=true
|
||||||
|
ricoh.dalp.install.destination=hdd
|
||||||
|
ricoh.dalp.install.mode.auto=true
|
||||||
|
ricoh.dalp.install.work-dir=hdd
|
||||||
|
ricoh.dalp.is-managed=true
|
||||||
|
ricoh.dalp.resources.dsdk.version=2.0
|
||||||
|
ricoh.dalp.resources.jar.basepath=
|
||||||
|
ricoh.dalp.resources.jar.version=
|
||||||
|
ricoh.dalp.version=
|
||||||
|
ricoh.icon.invert=false
|
||||||
|
ricoh.platform.target.version=
|
||||||
|
run.cmd.options=
|
||||||
|
run.jvmargs=
|
||||||
|
run.method=STANDARD
|
||||||
|
run.security.domain=trusted
|
||||||
|
run.use.security.domain=false
|
||||||
|
savaje.application.icon=
|
||||||
|
savaje.application.icon.focused=
|
||||||
|
savaje.application.icon.small=
|
||||||
|
savaje.application.uid=TBD
|
||||||
|
savaje.bundle.base=
|
||||||
|
savaje.bundle.debug=false
|
||||||
|
savaje.bundle.debug.port=
|
||||||
|
semc.application.caps=
|
||||||
|
semc.application.icon=
|
||||||
|
semc.application.icon.count=
|
||||||
|
semc.application.icon.splash=
|
||||||
|
semc.application.icon.splash.installonly=false
|
||||||
|
semc.application.uid=E5342786
|
||||||
|
semc.certificate.path=
|
||||||
|
semc.private.key.password=
|
||||||
|
semc.private.key.path=
|
||||||
|
sign.alias=
|
||||||
|
sign.enabled=false
|
||||||
|
sign.keystore=
|
||||||
|
src.dir=src
|
||||||
|
use.emptyapis=true
|
||||||
|
use.preprocessor=true
|
10
nbproject/project.xml
Normal file
10
nbproject/project.xml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://www.netbeans.org/ns/project/1">
|
||||||
|
<type>org.netbeans.modules.kjava.j2meproject</type>
|
||||||
|
<configuration>
|
||||||
|
<data xmlns="http://www.netbeans.org/ns/j2me-project">
|
||||||
|
<name>HSVScreenSaver</name>
|
||||||
|
<minimum-ant-version>1.6</minimum-ant-version>
|
||||||
|
</data>
|
||||||
|
</configuration>
|
||||||
|
</project>
|
104
src/Canv.java
Normal file
104
src/Canv.java
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
/*
|
||||||
|
* To change this template, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import com.nokia.mid.ui.DeviceControl;
|
||||||
|
import javax.microedition.lcdui.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author aNNiMON
|
||||||
|
*/
|
||||||
|
public class Canv extends Canvas implements Runnable {
|
||||||
|
|
||||||
|
private int w,h,step;
|
||||||
|
private boolean stb, ltb, itb, light;
|
||||||
|
private long time;
|
||||||
|
private HSV hsv;
|
||||||
|
private Thread thr;
|
||||||
|
|
||||||
|
public Canv() {
|
||||||
|
setFullScreenMode(true);
|
||||||
|
w = getWidth();
|
||||||
|
h = getHeight();
|
||||||
|
stb = false;
|
||||||
|
step = 2;
|
||||||
|
checkResolution(Main.midlet.img);
|
||||||
|
hsv = new HSV();
|
||||||
|
thr = new Thread(this);
|
||||||
|
thr.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void paint(Graphics g) {
|
||||||
|
g.setColor(0);
|
||||||
|
g.fillRect(0, 0, w, h);
|
||||||
|
g.drawImage(Main.midlet.img, w/2, h/2, 3);
|
||||||
|
if(stb) {
|
||||||
|
drawUI(g);
|
||||||
|
g.setColor(0xE8E8E8);
|
||||||
|
g.drawString("Step "+String.valueOf(step), w/2, h-2, 33);
|
||||||
|
if(System.currentTimeMillis()-time>=3000) stb=false;
|
||||||
|
repaint();
|
||||||
|
}
|
||||||
|
if(ltb) {
|
||||||
|
drawUI(g);
|
||||||
|
g.setColor(0xE8E8E8);
|
||||||
|
g.drawString("Lights "+String.valueOf(light), w/2, h-2, 33);
|
||||||
|
if(System.currentTimeMillis()-time>=3000) ltb=false;
|
||||||
|
repaint();
|
||||||
|
}
|
||||||
|
if(itb) {
|
||||||
|
drawUI(g);
|
||||||
|
g.setColor(0xE8E8E8);
|
||||||
|
g.drawString("Author: aNNiMON", w/2, h-2, 33);
|
||||||
|
if(System.currentTimeMillis()-time>=3000) itb=false;
|
||||||
|
repaint();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void drawUI(Graphics g) {
|
||||||
|
Font fnt = Font.getFont(0, Font.STYLE_BOLD, Font.SIZE_MEDIUM);
|
||||||
|
int fh = fnt.getHeight()+4;
|
||||||
|
int[] ui = new int[(w-10)*fh];
|
||||||
|
for(int i=0; i<ui.length; i++) {
|
||||||
|
ui[i]=0xAA555555;
|
||||||
|
}
|
||||||
|
g.drawRGB(ui, 0, w-10, 5, h-fh, w-10, fh, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void keyPressed(int key) {
|
||||||
|
int ga=getGameAction(key);
|
||||||
|
if(ga==UP) {step++; if(step>30) step=1; stb = true;}
|
||||||
|
if(ga==DOWN) {step--; if(step<1) step=30; stb = true;}
|
||||||
|
if(ga==FIRE) {light=!light; ltb = true;}
|
||||||
|
if(key==KEY_STAR) {itb = true;}
|
||||||
|
if(key==KEY_NUM0) Main.midlet.destroyApp(true);
|
||||||
|
time = System.currentTimeMillis();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void keyRepeated(int key) {
|
||||||
|
keyPressed(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkResolution(Image img) {
|
||||||
|
if(img.getWidth()>w && img.getHeight()>h) {
|
||||||
|
Image temp = Image.createImage(w, h);
|
||||||
|
Graphics g = temp.getGraphics();
|
||||||
|
g.drawImage(img, w/2, h/2, 3);
|
||||||
|
Main.midlet.img=temp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void run() {
|
||||||
|
while(true) {
|
||||||
|
hsv.hsb(step);
|
||||||
|
repaint();
|
||||||
|
if(light) DeviceControl.setLights(0, 100);
|
||||||
|
try {
|
||||||
|
Thread.sleep(100);
|
||||||
|
} catch (InterruptedException ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
93
src/HSV.java
Normal file
93
src/HSV.java
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
/*
|
||||||
|
* To change this template, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import javax.microedition.lcdui.Image;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author aNNiMON
|
||||||
|
*/
|
||||||
|
public class HSV {
|
||||||
|
|
||||||
|
private int[] pixel;
|
||||||
|
private int wdh, hgt;
|
||||||
|
|
||||||
|
public HSV() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void hsb(int ch) {
|
||||||
|
Image img = Main.midlet.img;
|
||||||
|
wdh = img.getWidth();
|
||||||
|
hgt = img.getHeight();
|
||||||
|
pixel = new int[wdh * hgt];
|
||||||
|
int[] lineRGB = new int[wdh];
|
||||||
|
for (int y = 0; y < hgt; y++) {
|
||||||
|
img.getRGB(lineRGB, 0, wdh, 0, y, wdh, 1);
|
||||||
|
System.arraycopy(lineRGB, 0, pixel, y*wdh, lineRGB.length);
|
||||||
|
}
|
||||||
|
float[] hsb = new float[3];
|
||||||
|
for (int io = 0; io < pixel.length; io++) {
|
||||||
|
int qa = (pixel[io] >> 24) & 0xff;
|
||||||
|
int qr = (pixel[io] >> 16) & 0xff;
|
||||||
|
int qg = (pixel[io] >> 8) & 0xff;
|
||||||
|
int qb = pixel[io] & 0xff;
|
||||||
|
hsb = RGBtoHSV(qr, qg, qb, hsb);
|
||||||
|
hsb[0] = hsb[0] + ch;
|
||||||
|
pixel[io] = (qa << 24) | HSVtoRGB(hsb[0], hsb[1], hsb[2]);
|
||||||
|
}
|
||||||
|
Main.midlet.img = Image.createRGBImage(pixel, wdh, hgt, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
private int HSVtoRGB(float h, float s, float v) {
|
||||||
|
float qr = 0, qg = 0, qb = 0;
|
||||||
|
int r = 0, g = 0, b = 0;
|
||||||
|
if(s==0.0 && h==-1.0) return ((int)v << 16) | ((int)v << 8) | (int)v;
|
||||||
|
int Hi = (int) ((h / 60) % 6);
|
||||||
|
float f = (float) (h / 60 - (float)Math.floor(h/60));
|
||||||
|
float p = (float) ((float)v*(1.0f - (float)s));
|
||||||
|
float q = (float) ((float)v*(1.0f - (float)f*(float)s));
|
||||||
|
float t = (float) ((float)v*(1.0f - (s*(1.0-f))));
|
||||||
|
switch(Hi) {
|
||||||
|
case 0: qr = v; qg = t; qb = p; break;
|
||||||
|
case 1: qr = q; qg = v; qb = p; break;
|
||||||
|
case 2: qr = p; qg = v; qb = t; break;
|
||||||
|
case 3: qr = p; qg = q; qb = v; break;
|
||||||
|
case 4: qr = t; qg = p; qb = v; break;
|
||||||
|
case 5: qr = v; qg = p; qb = q; break;
|
||||||
|
}
|
||||||
|
r = (int) (255 * qr); g = (int) (255 * qg); b = (int) (255 * qb);
|
||||||
|
return (r << 16) | (g << 8) | b;
|
||||||
|
}
|
||||||
|
|
||||||
|
private float[] RGBtoHSV(int qr, int qg, int qb, float[] hsv) {
|
||||||
|
float h = 0, s, v;
|
||||||
|
if (hsv == null) {
|
||||||
|
hsv = new float[3];
|
||||||
|
}
|
||||||
|
float r = (float) qr/255; float g = (float) qg/255; float b = (float) qb/255;
|
||||||
|
float max = (r > g) ? r : g;
|
||||||
|
if (b > max) max = b;
|
||||||
|
float min = (r < g) ? r : g;
|
||||||
|
if (b < min) min = b;
|
||||||
|
// hue
|
||||||
|
if(max==min) h=0;
|
||||||
|
if(max==r && g>=b) h = 60 * ((g-b)/(max-min));
|
||||||
|
if(max==r && g<b) h = 60 * ((g-b)/(max-min))+360;
|
||||||
|
if(max==g) h = 60 * ((b-r)/(max-min))+120;
|
||||||
|
if(max==b) h = 60 * ((r-g)/(max-min))+240;
|
||||||
|
//saturation
|
||||||
|
if(max==0) s = 0;
|
||||||
|
else s=((max - min)/max);//1-(min/max);
|
||||||
|
if(s==0) h=-1;
|
||||||
|
// value
|
||||||
|
v = max;
|
||||||
|
|
||||||
|
hsv[0] = h;
|
||||||
|
hsv[1] = s;
|
||||||
|
hsv[2] = v;
|
||||||
|
return hsv;
|
||||||
|
}
|
||||||
|
}
|
58
src/Main.java
Normal file
58
src/Main.java
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
* To change this template, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import javax.microedition.lcdui.*;
|
||||||
|
import javax.microedition.midlet.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author aNNiMON
|
||||||
|
*/
|
||||||
|
public class Main extends MIDlet {
|
||||||
|
|
||||||
|
public static Main midlet;
|
||||||
|
public Display dsp;
|
||||||
|
public Image img;
|
||||||
|
|
||||||
|
public Main() {
|
||||||
|
midlet=this;
|
||||||
|
dsp = Display.getDisplay(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void startApp() {
|
||||||
|
try {
|
||||||
|
img = Image.createImage("/1.png");
|
||||||
|
} catch (IOException ex) {
|
||||||
|
try {
|
||||||
|
img = Image.createImage("/1.jpg");
|
||||||
|
} catch (IOException ex1) {
|
||||||
|
try {
|
||||||
|
img = Image.createImage("/1.gif");
|
||||||
|
} catch (IOException ex2) {
|
||||||
|
try {
|
||||||
|
img = Image.createImage("/1.bmp");
|
||||||
|
} catch (IOException ex3) {
|
||||||
|
img = Image.createImage(100, 100);
|
||||||
|
Graphics G = img.getGraphics();
|
||||||
|
G.setColor(0xFF0000);
|
||||||
|
G.drawString("-_+ Бу-га-га О_о >_<", 0, 0, 20);
|
||||||
|
G.setColor(0x00FF00);
|
||||||
|
G.drawString("Закинь в меня -_-", 50, 50, 17);
|
||||||
|
G.setColor(0x0000FF);
|
||||||
|
G.drawString("картинку 1.png =)", 100, 100, 40);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dsp.setCurrent(new Canv());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void pauseApp() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public void destroyApp(boolean un) {
|
||||||
|
notifyDestroyed();
|
||||||
|
}
|
||||||
|
}
|
BIN
src/icon.png
Normal file
BIN
src/icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 463 B |
Loading…
Reference in New Issue
Block a user