int bgColor = processColorString( _widgetConfigImpl.getLoadingScreenColor() );
if( _widgetConfigImpl.getBackgroundImage().length() != 0 ) {
// Set background image
EncodedImage backgroundImage = EncodedImage.getEncodedImageResource( _widgetConfigImpl.getBackgroundImage() );
if( backgroundImage != null ) {
// Resize the image to the display size.
int scaleX = Fixed32.div( Fixed32.toFP( backgroundImage.getWidth() ), Fixed32.toFP( Display.getWidth() ) );
int scaleY = Fixed32.div( Fixed32.toFP( backgroundImage.getHeight() ), Fixed32.toFP( Display.getHeight() ) );
EncodedImage scaledBgImage = backgroundImage.scaleImage32(scaleX, scaleY);
// Using the scaled bg image draw onto the blank white bitmap.
Bitmap bgImg = new Bitmap( scaledBgImage.getScaledWidth(), scaledBgImage.getScaledHeight() );
Graphics g = new Graphics( bgImg );
if( bgColor != -1 ) {
g.setColor( bgColor );
} else {
g.setColor( Color.WHITE );
}
g.fillRect( 0, 0, scaledBgImage.getScaledWidth(), scaledBgImage.getScaledHeight() );
g.drawImage( 0, 0, scaledBgImage.getScaledWidth(), scaledBgImage.getScaledHeight(),
scaledBgImage, 0, 0, 0 );
Background bg = BackgroundFactory.createBitmapBackground( bgImg,
Background.POSITION_X_CENTER, Background.POSITION_Y_CENTER, Background.REPEAT_SCALE_TO_FIT );
this.setBackground( bg );
this.getMainManager().setBackground( bg );
}
} else {
// -1 denotes an invalid color
if( bgColor != -1 ) {
Background color = BackgroundFactory.createSolidBackground( bgColor );
this.setBackground( color );
this.getMainManager().setBackground( color );
}
}
if( _widgetConfigImpl.getForegroundImage().length() != 0 ) {
EncodedImage foregroundImage = EncodedImage.getEncodedImageResource( _widgetConfigImpl.getForegroundImage() );
if( foregroundImage != null ) {
_hfm = new HorizontalFieldManager( Manager.NO_HORIZONTAL_SCROLL | Manager.NO_VERTICAL_SCROLL
| Field.NON_FOCUSABLE | Field.FIELD_HCENTER );
if( foregroundImage instanceof GIFEncodedImage ) {
_foregroundImage = new AnimatedGIFField( (GIFEncodedImage) foregroundImage );
( ( AnimatedGIFField) _foregroundImage ).startAnimation();
} else {
_foregroundImage = new BitmapField( foregroundImage.getBitmap() );
}
// Add the _foregroundImage field
_hfm.add( _foregroundImage );