Commit 0a54ca55 authored by Stephanie Gawroriski's avatar Stephanie Gawroriski
Browse files

Implement Display.numAlphaLevels() and Display.numColors().

parent 79f21ea3
......@@ -65,6 +65,9 @@ More detailed changes:
to launched tasks.
* `midp-lcdui`
* Added a 12 strike font.
* Added support for getting the number of display colors which depends on
the pixel format of the display.
* Added support to get the number of alpha levels.
* Adjusted the style of the lowercase A character in the sans-serif font.
* Changed 16 strike font to be the large size font and made the 12 strike
font the medium size font.
......
......@@ -167,6 +167,78 @@ public enum PixelFormat
}
}
/**
* Returns the number of alpha levels.
*
* @return The number of alpha levels.
* @since 2019/05/05
*/
public final int numAlphaLevels()
{
switch (this)
{
case BYTE_INDEXED1:
case BYTE_INDEXED2:
case BYTE_INDEXED4:
case BYTE_INDEXED8:
case SHORT_INDEXED16:
case BYTE_RGB332:
case SHORT_RGB565:
case INTEGER_RGB888:
return 0;
case SHORT_ARGB4444:
return 16;
case INTEGER_ARGB8888:
return 256;
// Unknown
default:
throw new todo.OOPS(this.name());
}
}
/**
* Returns the number of possible colors.
*
* @return The number of possible colors.
* @since 2019/05/05
*/
public final int numColors()
{
switch (this)
{
case BYTE_INDEXED1:
return 2;
case BYTE_INDEXED2:
return 4;
case BYTE_INDEXED4:
return 16;
case BYTE_INDEXED8:
case BYTE_RGB332:
return 256;
case SHORT_ARGB4444:
return 4096;
case SHORT_INDEXED16:
case SHORT_RGB565:
return 65536;
case INTEGER_ARGB8888:
case INTEGER_RGB888:
return 16777216;
// Unknown
default:
throw new todo.OOPS(this.name());
}
}
/**
* Maps the pixel format ID to the pixel format type.
*
......
......@@ -22,7 +22,7 @@ import javax.microedition.lcdui.Graphics;
public final class UIFramebuffer
{
/** The pixel format of the buffer. */
protected final PixelFormat pixelformat;
public final PixelFormat pixelformat;
/** The buffer data. */
protected final Object buffer;
......
......@@ -619,7 +619,10 @@ public class Display
*/
public int numAlphaLevels()
{
throw new todo.TODO();
int rv = this._state.framebuffer().pixelformat.numAlphaLevels();
if (rv <= 2)
return 2;
return rv;
}
/**
......@@ -634,9 +637,7 @@ public class Display
*/
public int numColors()
{
throw new todo.TODO();
/*
return this._head.numColors();*/
return this._state.framebuffer().pixelformat.numColors();
}
public void removeCurrent()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment