|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.iproject.wbmpcreator.WBMPfile
Copyright (c) 2000 WAP Shareware, Inc. Visit WAP Shareware Visit WBMPcreator homepage
Field Summary | |
static int |
ALIGN_CENTER
|
static int |
ALIGN_HORIZONTAL_CENTER
A constant value used for aligning bitmaps. |
static int |
ALIGN_HORIZONTAL_LEFT
A constant value used for aligning bitmaps. |
static int |
ALIGN_HORIZONTAL_RIGHT
A constant value used for aligning bitmaps. |
static int |
ALIGN_VERTICAL_BOTTOM
A constant value used for aligning bitmaps. |
static int |
ALIGN_VERTICAL_CENTER
A constant value used for aligning bitmaps. |
static int |
ALIGN_VERTICAL_TOP
A constant value used for aligning bitmaps. |
static int |
APPEND_MODE_CONTINUOUS
A constant value used to append string to a bitmap. |
static int |
APPEND_MODE_DIVISION
A constant value used to append string to a bitmap. |
static int |
LINE_CHAIN3_1
Line will look like a chain line with 3-point long lines and 1-point spaces |
static int |
LINE_CHAIN3_2
Line will look like a chain line with 3-point long lines and 2-point spaces |
static int |
LINE_INT2_1
Line will look like a group of 2-point intervals lying on a single line and having 1-point space between intervals. |
static int |
LINE_INT2_2
Line will look like a group of 2-point intervals lying on a single line and having 2-point space between intervals. |
static int |
LINE_INT3_2
Line will look like a group of 3-point intervals lying on a single line and having 2-point space between intervals. |
static int |
LINE_POINT1
All points of a line will be drawn with 1 point interval |
static int |
LINE_POINT2
All points of a line will be drawn with 2 points interval |
static int |
LINE_POINT3
All points of a line will be drawn with 3 points interval |
static int |
MIX_MODE_AND
A constant value used for mixing bitmaps. |
static int |
MIX_MODE_NOT
A constant value used for mixing bitmaps. |
static int |
MIX_MODE_OR
A constant value used for mixing bitmaps. |
static int |
MIX_MODE_XOR
A constant value used for mixing bitmaps. |
Constructor Summary | |
WBMPfile()
Empty constructor. |
|
WBMPfile(byte[] bytes)
Constructor that creates WBMPfile instances from an array of
bytes (this can be useful in work with databases). |
|
WBMPfile(int length,
int width)
this constructor creates the blank WBMP file. |
|
WBMPfile(int length,
int width,
int[][] picData)
this constructor creates the WBMP file. |
|
WBMPfile(SimpleImageFile image,
int red,
int green,
int blue)
A new WBMPfile constructor from Image instance. |
|
WBMPfile(java.lang.String filename)
Constructor with the filename. |
|
WBMPfile(java.lang.String url,
int port)
Method to create WBMPfile instance from WEB This will help much in creating images based on the images stored somewhere in the Internet. |
|
WBMPfile(java.lang.String filename,
int filter,
boolean invert)
|
Method Summary | |
WBMPfile |
align(WBMPfile lowerLayer,
WBMPfile upperLayer,
int alignMethod,
int mixingMethod)
Method for aligning images one relative to another. |
void |
convert2WBMPfile(java.lang.String filename)
Method to convert image into the WBMP format. |
void |
convert2WBMPfile(java.net.URL imageURL)
Method to convert remote image into the WBMP format. |
void |
createWBMPFile()
Method to create the new WBMPfile filled with white. |
void |
destroyWBMPFile()
Removes the WBMPfile instance from memory. |
void |
draw3DRect(int x,
int y,
int length,
int width,
boolean isFilled,
boolean isRaised)
Method to draw a 3D rectangle. |
void |
drawArc(int x,
int y,
int width,
int height,
int startAngle,
int arcAngle)
Method drawing the arc with the following parameters: |
void |
drawCircle(int x,
int y,
int radius,
int color,
boolean isFilled)
Method to draw a circle. |
void |
drawCustomString(java.lang.String text,
int X,
int Y,
java.lang.String inFont,
int direction)
Method to draw text with custom font on the current layer. |
void |
drawLine(int x_1,
int y_1,
int x_2,
int y_2)
Method to draw a line on the lower layer (current layer). |
void |
drawOval(int x,
int y,
int length,
int width,
boolean isFilled)
Method to draw oval with the selected length and width |
void |
drawPoint(int x,
int y,
int color)
Method to draw a point with the selected color at the coordinates X, Y. |
void |
drawRect(int x,
int y,
int length,
int width,
boolean isFilled)
Method to draw a rectangle. |
void |
drawSpecialLine(int x1,
int y1,
int x2,
int y2,
int line_type,
int color)
Method to draw a special line. |
void |
drawString(java.lang.String text,
int X,
int Y,
java.awt.Font inFont)
Method to draw text on the current layer. |
WBMPfile |
drawTTFString(java.lang.String text,
java.awt.Font font)
Method to get a WBMPfile instance of a TTF string written
with the selected font. |
static WBMPfile |
executeSequence(java.lang.String seq_name)
Method to execute sequence - a set of instructions for automatic images generation. |
byte[] |
getByteArray(java.lang.String format)
This method gets the byte representation of a resulting image. |
int |
getElementAt(int X,
int Y)
this int returns the value of the desired point |
WBMPfile |
getRectArea(WBMPDimension area)
Method to get a piece of an image. |
java.lang.String |
getString()
This method returns java.lang.String representation of a WBMPfile. |
int |
getWBMPLength()
Gets the length of the image. |
int[][] |
getWBMPpic()
Method to let user obtain point arrays without delay. |
int |
getWBMPWidth()
Gets the width of the image. |
void |
invertWBMPImage()
This method inverts image so that all black pixels turn into white and vice versa. |
WBMPfile |
mix(WBMPfile layer1,
int mixMode)
this function mixes the given picture with the current. |
WBMPfile |
mix(WBMPfile layer1,
int mixMode,
int X,
int Y)
this function mixes the given picture with the current. |
WBMPfile |
openEWBMPFile(java.lang.String filename)
Support for EWBMP image format. |
WBMPfile |
openWBMPFile(java.lang.String filename)
Method to read WBMPfile from the disk and to create a WBMPfile instance in memory. |
void |
printWBMPImage()
Method to put WBMP image's contents to the screen. |
WBMPfile |
reduce(int bgColor)
A very useful methos to find the actual image size. |
WBMPfile |
rotate(int angle)
Method to rotate a WBMP image. |
void |
saveEWBMP2File(java.lang.String filename)
This method saves the EWBMP file. |
void |
saveWBMPFile(java.lang.String format,
java.lang.String filename)
Universal method for saving WBMP files in different formats Available parameters: BMP PNG JPG TIFF WBMP EWBMP |
void |
setElementAt(int X,
int Y,
int value)
this void assigns value to the given cell |
void |
setWBMPLength(int newLength)
Sets the new length of the image. |
void |
setWBMPWidth(int newWidth)
Sets the new width of the image. |
void |
writeWBMPFile(java.lang.String format,
java.io.OutputStream stream)
Universal method for saving WBMP files in different formats Available parameters: BMP PNG JPG TIFF WBMP EWBMP |
Methods inherited from class java.lang.Object |
equals,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Field Detail |
public static final int MIX_MODE_XOR
public static final int MIX_MODE_AND
public static final int MIX_MODE_OR
public static final int MIX_MODE_NOT
public static final int ALIGN_HORIZONTAL_LEFT
public static final int ALIGN_HORIZONTAL_RIGHT
public static final int ALIGN_HORIZONTAL_CENTER
public static final int ALIGN_VERTICAL_TOP
public static final int ALIGN_VERTICAL_BOTTOM
public static final int ALIGN_VERTICAL_CENTER
public static final int ALIGN_CENTER
public static final int APPEND_MODE_DIVISION
public static final int APPEND_MODE_CONTINUOUS
public static final int LINE_POINT1
public static final int LINE_POINT2
public static final int LINE_POINT3
public static final int LINE_INT2_1
public static final int LINE_INT2_2
public static final int LINE_INT3_2
public static final int LINE_CHAIN3_1
public static final int LINE_CHAIN3_2
Constructor Detail |
public WBMPfile()
public WBMPfile(java.lang.String filename) throws java.io.IOException
public WBMPfile(int length, int width)
length
- the length of a WBMP file in pixelswidth
- the width of a WBMP image in pixelspublic WBMPfile(int length, int width, int[][] picData)
length
- the length of a WBMP file in pixelswidth
- the width of a WBMP image in pixelspicData
- the array of points of a WBMP filepublic WBMPfile(java.lang.String url, int port)
url
- the URL of a wbmp file. MUST be with "http://" or another beginning.port
- port for the URL (for HTTP it is 80)Example:
// something before opening the image from Internet // opening WBMPfile wf=new WBMPfile("http://wbmpcreator.iproject.ru/Training/chart.wbmp"); // other actions with the image
If an image is unavailable, a blank 96x44 image is created instead.
public WBMPfile(byte[] bytes)
WBMPfile
instances from an array of
bytes (this can be useful in work with databases).bytes
- the array of bytes containing contents of a WBMP filepublic WBMPfile(SimpleImageFile image, int red, int green, int blue)
SimpleImageFile sif=new SimpleImageFile("your_filename"); WBMPfile wf=new WBMPfile(sif, 128,128,128); // for constant threshold wf.saveWBMP2File("your_filename.wbmp");
The following example shows how to use adoptive thresolds:
SimpleImageFile sif=new SimpleImageFile("your_filename"); WBMPfile wf=new WBMPfile(sif, -1,-1,-1); // for adoptive threshold wf.saveWBMP2File("your_filename.wbmp");
If you want to use adoptive threshold for only selected color channels, just use the following construction (here RED color is static):
SimpleImageFile sif=new SimpleImageFile("your_filename"); WBMPfile wf=new WBMPfile(sif, 128,-1,-1); // for adoptive threshold wf.saveWBMP2File("your_filename.wbmp");In this example only GREEN and BLUE color channels use adoptive threshold, and RED channel is set to 128 imdependent from what is set as a parameter.
image
- the SimpleImageFile instancered
- the RED thresholdgreen
- the GREEN thresholdblue
- the BLUE thresholdpublic WBMPfile(java.lang.String filename, int filter, boolean invert) throws java.lang.InterruptedException
Method Detail |
public void setWBMPLength(int newLength)
public int getWBMPLength()
public void setWBMPWidth(int newWidth)
public int getWBMPWidth()
public void createWBMPFile()
length
and width
must be specified before!public void destroyWBMPFile()
public void setElementAt(int X, int Y, int value)
public int getElementAt(int X, int Y)
public void printWBMPImage()
public void invertWBMPImage()
public WBMPfile mix(WBMPfile layer1, int mixMode)
layer1
- the upper layer (the given picture)mixMode
- the way to mix the picturespublic WBMPfile mix(WBMPfile layer1, int mixMode, int X, int Y)
layer1
- the upper layer (the given picture)mixMode
- the way to mix the picturesX
- the upper left X coordinate of the lower layerY
- the upper left Y coorinate of the lower layerpublic void drawString(java.lang.String text, int X, int Y, java.awt.Font inFont)
text
- the text to be drawnX
- the lower left X coordinate of the layerY
- the lower left Y coordinate of the layerinFont
- the TTF font to be used
NOTE that it can work on Java version 1.2 and higher platforms.
public void drawCustomString(java.lang.String text, int X, int Y, java.lang.String inFont, int direction) throws java.io.FileNotFoundException
text
- the text to be drawnX
- the lower left X coordinate of the layerY
- the lower left Y coordinate of the layerinFont
- the custom font to be used (refer to documentation for
details). If you want to use the built-in custon 4x6 font -
set this parameter to STANDARD
public void drawLine(int x_1, int y_1, int x_2, int y_2)
x_1
- X coordinate of FROM pointy_1
- Y coordinate of FROM pointx_2
- X coordinate of TO pointy_2
- Y coordinate of TO point
Benchmark: Intel Pentium III - 600, 128 Mb RAM PC-133 0(!!!)ms
public void drawOval(int x, int y, int length, int width, boolean isFilled)
x
- X coordinate of left upper cornery
- Y coordinate of left upper cornerlength
- length of the ovalwidth
- width of the ovalisFilled
- fills (true) or not (false) the oval
Benchmark: Intel Pentium III - 600, 128 Mb RAM PC-133 0(!!!)ms
public void drawPoint(int x, int y, int color)
x
- X coordinate of a pointy
- Y coordinate of a pointcolor
- the color of a point.
NOTE! Due to WAP phones support only b&w picture mode, it's better to
use 1 and 0 colors.public void drawRect(int x, int y, int length, int width, boolean isFilled)
x
- X coordinate of upper left corner of a rectangley
- Y coordinate of upper left corner of a rectanglelength
- length of a rectanglewidth
- width of a rectangleisFilled
- fills (true) or not (false) the rectangle
Benchmark: Intel Pentium III - 600, 128 Mb RAM PC-133 0(!!!)ms
public void draw3DRect(int x, int y, int length, int width, boolean isFilled, boolean isRaised)
x
- X coordinate of upper left corner of a 3D rectangley
- Y coordinate of upper left corner of a 3D rectanglelength
- length of a 3D rectanglewidth
- width of a 3D rectangleisFilled
- fills (true) or not (false) a 3D rectangleisRaised
- is the border raised? true/false
Benchmark: Intel Pentium III - 600, 128 Mb RAM PC-133 0(!!!)ms
public void drawArc(int x, int y, int width, int height, int startAngle, int arcAngle)
x
- the X coordinate of the left upper point of a rectangle containing the arcy
- the X coordinate of the left upper point of a rectangle containing the arcwidth
- the width of a rectangle containing the archeight
- the height of a rectangle containing the arcstartAngle
- refer to java.awt.Graphics for detailsarcAngle
- refer to java.awt.Graphics for details
Benchmark: Intel Pentium III - 600, 128 Mb RAM PC-133 0(!!!)ms
public java.lang.String getString()
saveWBMP2File()
writes the file to the disk and
this metod returns a string available fo any future use.WBMPcreator.WBMPfile#saveWBMP2File()
public WBMPfile rotate(int angle)
angle
variableangle
- an integer representing quantity of Pi/2 rotations in
positive direction (mathematicians will understand me :-|). I.e. if
angle equals 0 then the image remains the same. If angle is even then
dimensions also remain the same and if it is equal to n*4 where n is
an integer then the picture returned is equal to current. Odd values
of angle modify dimensions.public WBMPfile getRectArea(WBMPDimension area)
area
- a dimensionWBMPcreator.WBMPDimension#WBMPDimension()
public int[][] getWBMPpic()
public void drawCircle(int x, int y, int radius, int color, boolean isFilled)
x
- the centre point x axis coordinatey
- the centre point y axis coordinateradius
- the radius of a circlecolor
- the color of a circleisFilled
- is the circle filledBenchmark: Intel Pentium III - 600, 128 Mb RAM PC-133 0(!!!)ms
public void drawSpecialLine(int x1, int y1, int x2, int y2, int line_type, int color)
x1
- the first point x axis coordinatey1
- the first point y axis coordinatex2
- the second point x axis coordinatey2
- the second point y axis coordinateline_type
- the type of a special linecolor
- the color of a lineBenchmark: Intel Pentium III - 600, 128 Mb RAM PC-133 0 (!!!) ms Note that the dotted line can be like the simple line. In this case you should increase the point-to-point interval. It is connected with the angle of a line.
public WBMPfile openEWBMPFile(java.lang.String filename) throws java.io.IOException
A short glance at EWBMP. It's not a standard of Nokia or any other WAP
standard developers. It's just a useful tip. All EWBMP instances are handled
as ordinary WBMP with one exception: to save the EWBMP file you should use
this method because the result of saveWBMP2File
method will give
just WBMPLength%256 and WBMPWidth%256 dimensions which will not be correct.
The only difference between WBMP and EWBMP is that the second format uses the 2-bytes representation of either length and width of an image instead of 1 byte. Thus, the resulting image can have dimension up to 65535*65535 points. I don't really know the sphere of usage of these large files but support for them, I believe, will be necessary in future.
This method opens the EWBMP file and reads its content to a WBMPfile instance (its inner realization supports large images).
filename
- the filename of a EWBMP imagepublic void saveEWBMP2File(java.lang.String filename)
openEWBMPFile
method.filename
- the filename of a EWBMP imagepublic static WBMPfile executeSequence(java.lang.String seq_name) throws java.io.FileNotFoundException, BadSequenceLineException
WBMPfile
instance.
A sequence file MUST have the *.wbmpseq extension.
Some words about sequences. As follows from its definition, a sequence is a set of instructions that guide the program what to do. A sequence language is very simple: just mention the function you want to execute regarding current image. This is the full list of keywords and syntax elements of the sequence language (all instructions are case-sensitive, booleans are represented as true or false; Strings look like "a string"):
# - the comment symbol. All characters after this symbol will be removed. If this symbol meets in the text (for example, as a text part), it should be duplicated.
SIZE x y the size of a resulting image. If this instruction is not mentioned - the resulting image will have 96x45 resolution.
DRAWARC x y width height startAngle arcAngle
DRAWCIRCLE x y radius color isFilled
DRAWLINE x_1 y_1 x_2 y_2
DRAWOVAL x y length width isFilled
DRAWPOINT x y color
DRAWRECT x y length width isFilled
DRAW3DRECT x y length width isFilled isRaised
DRAWSPECIALLINE x1 y1 x2 y2 line_type color
DRAWCUSTOMSTRING text X Y inFont set inFont to "CUSTOM" is you wish to use the built-in font
Descriptions to all methods are available at the appropriate methods. This will be very useful for automating the creative process.
seq_name
- the filename of a sequence WITHOUT extensionpublic WBMPfile openWBMPFile(java.lang.String filename) throws java.io.IOException
filename
- the name of a file to be read.public void convert2WBMPfile(java.lang.String filename)
filename
- the filename of an imagepublic void convert2WBMPfile(java.net.URL imageURL)
filename
- the filename of an imagepublic void saveWBMPFile(java.lang.String format, java.lang.String filename)
public void writeWBMPFile(java.lang.String format, java.io.OutputStream stream)
public byte[] getByteArray(java.lang.String format)
byte[] _dataOut=image.getByteArray("OTA");
public WBMPfile align(WBMPfile lowerLayer, WBMPfile upperLayer, int alignMethod, int mixingMethod)
lowerLayer
- the WBMPfile instance which lies UNDER the other imageopperLayer
- the WBMPfile instance which lies ABOVE the other imagealignMethod
- the type of aligning imagesmixingMethod
- the type of mixinglowerlayer
must be larger than the
upperLayer
.public WBMPfile drawTTFString(java.lang.String text, java.awt.Font font)
WBMPfile
instance of a TTF string written
with the selected font. NOTE that any string written with TTF font can be
visible only if the font size is equal or exceeds 10.text
- the text to be writtenfont
- the java.awt.Font
instance to be usedWBMPfile
instance of a TTF stringpublic WBMPfile reduce(int bgColor)
WBMPfile
with 30x10
dimensions. This method works correctly only if the background doesn't
contain any point not relating to the actual image.bgColor
- the background color (1 relates to BLACK, 0 related to WHITE)WBMPfile
instance of a resulting area
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |