FileDocCategorySizeDatePackage
ImageHelper.javaAPI DocAndroid 1.5 API3063Wed May 06 22:41:08 BST 2009com.android.ddmuilib

ImageHelper

public class ImageHelper extends Object

Fields Summary
Constructors Summary
Methods Summary
public static org.eclipse.swt.graphics.ImagecreatePlaceHolderArt(org.eclipse.swt.widgets.Display display, int width, int height, org.eclipse.swt.graphics.Color color)
Create place-holder art with the specified color.

        Image img = new Image(display, width, height);
        GC gc = new GC(img);
        gc.setForeground(color);
        gc.drawLine(0, 0, width, height);
        gc.drawLine(0, height - 1, width, -1);
        gc.dispose();
        return img;
    
public static org.eclipse.swt.graphics.ImageloadImage(IImageLoader loader, org.eclipse.swt.widgets.Display display, java.lang.String fileName, int width, int height, org.eclipse.swt.graphics.Color phColor)
Loads an image from a resource. This method used a class to locate the resources, and then load the filename from /images inside the resources.
Extra parameters allows for creation of a replacement image of the loading failed.

param
loader the image loader used.
param
display the Display object
param
fileName the file name
param
width optional width to create replacement Image. If -1, null be be returned if the loading fails.
param
height optional height to create replacement Image. If -1, null be be returned if the loading fails.
param
phColor optional color to create replacement Image. If null, Blue color will be used.
return
a new Image or null if the loading failed and the optional replacement size was -1


        Image img = null;
        if (loader != null) {
            img = loader.loadImage(fileName, display);
        }

        if (img == null) {
            Log.w("ddms", "Couldn't load " + fileName);
            // if we had the extra parameter to create replacement image then we
            // create and return it.
            if (width != -1 && height != -1) {
                return createPlaceHolderArt(display, width, height,
                        phColor != null ? phColor : display
                                .getSystemColor(SWT.COLOR_BLUE));
            }

            // otherwise, just return null
            return null;
        }

        return img;