Package net.rim.device.api.system

Examples of net.rim.device.api.system.Bitmap


    mCheckCodeTextView = new RichTextField();
    mCheckCodeTextView.setText(sResources.getString(CHECK_CODE));

    mCodeArea = new HorizontalFieldManager(FIELD_HCENTER);

    Bitmap bitmap = Bitmap.getBitmapResource("ic_lock_lock.png");
    BitmapField icon = new BitmapField(bitmap, FIELD_VCENTER);

    mCodeTextView = new LabelField("", FIELD_VCENTER);
    mCodeArea.add(icon);
    mCodeArea.add(mCodeTextView);
View Full Code Here


       * fileName = "file:///store/home/user/pictures/screen_" + fileTimeStamp + ".png";
       */
      if (args.length == 1)
      {
        //Step 1: Save the screen to a BitMap object:
        Bitmap bitmapScreen = new Bitmap(Display.getWidth(), Display.getHeight());
        Display.screenshot(bitmapScreen);


        //Step 2: save image to the file system:
        String fileName = args[0].toString();
View Full Code Here

                     bm = writer.encode(contents, format, width, height,hints);
                  }catch(ClassCastException cce){
                    throw new Exception("ZXing Barcode Writer FAILURE - try different paramteres and pray");
                  }
                  //Bitmap b = BarcodeBitmap.createBitmap(bm,0);
                  Bitmap b = new Bitmap(width,height);

                  byte[][] array = bm.getArray();
                  //iterate through the matrix and draw the pixels to the image
                  //a Jeff and BT super hack to make generating a barcode work
                  for (int y = 0; y < height; y++) {
                    int[] argbArray = new int[width];
                   for (int x = 0; x < width; x++) {
                    int grayValue = array[y][x] & 0xff;
                    int pixel = (grayValue == 0 ? 0xFF000000 : 0xFFFFFFFF);
                    argbArray[x] = pixel;
                   }
                   b.setARGB(argbArray,0, width, 0,y, width, 1);
                  }
                 
                 

View Full Code Here

              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 );
View Full Code Here

     *            If the Dialog is a global dialog.
     */
    public DialogRunner( Dialog dialog, boolean isGlobal ) {
        _dialog = dialog;
        _global = isGlobal;
        Bitmap bitmap = Bitmap.getPredefinedBitmap( Bitmap.QUESTION );
        setIcon( bitmap );
        // _dialog.setOverlapping( true );
    }
View Full Code Here

    protected void layout( int width, int height ) {
        width = getPreferredWidth();
        height = getPreferredHeight();

        _rainbow = new Bitmap( width, height );
        Graphics rainbowGraphics = Graphics.create( _rainbow );
        rainbowGraphics.drawShadedFilledPath( _xcoords, _ycoords, null, _colors, null );

        setExtent( width, height );
    }
View Full Code Here

        _xcoords = new int[] { 0, 0, width, width };
        _ycoords = new int[] { 0, height, height, 0 };
        _colors = new int[] { 0xFFFFFF, 0x000000, 0x000000, _baseColor };

        // make new bitmap
        _backgroundBitmap = new Bitmap( width, height );// Bitmap.ROWWISE_MONOCHROME , width, height);// Bitmap.DEFAULT_TYPE,
                                                        // width, height );
        Graphics bitmapGraphics = Graphics.create( _backgroundBitmap );
        bitmapGraphics.drawShadedFilledPath( _xcoords, _ycoords, null, _colors, null );

        // Update selected color
View Full Code Here

            int type = listItem.getType();
            Font font = graphics.getFont();
            final int checkboxSize = font.getHeight() - 6;
            final int textStart = PADDING + checkboxSize + 10;

            Bitmap checkWhite = GPATools.ResizeTransparentBitmap( Bitmap.getBitmapResource( "chk-white.png" ), checkboxSize,
                    checkboxSize, Bitmap.FILTER_BOX, Bitmap.SCALE_TO_FILL );
            Bitmap checkBlue = GPATools.ResizeTransparentBitmap( Bitmap.getBitmapResource( "chk-blue.png" ), checkboxSize,
                    checkboxSize, Bitmap.FILTER_BILINEAR, Bitmap.SCALE_TO_FILL );
            Bitmap boxEmpty = GPATools.ResizeTransparentBitmap( Bitmap.getBitmapResource( "box-empty.png" ), checkboxSize,
                    checkboxSize, Bitmap.FILTER_BILINEAR, Bitmap.SCALE_TO_FILL );

            switch( type ) {
                case SelectAsyncFunction.POPUP_ITEM_TYPE_SEPARATOR:
                    graphics.setColor( Color.GRAY );
View Full Code Here

        int nOriginHeight = bmpSrc.getHeight();
        if(nWidth == nOriginWidth && nHeight == nOriginHeight)
            return bmpSrc;

        //Prepare a drawing bitmap and graphic object
        Bitmap bmpOrigin = new Bitmap(nOriginWidth, nOriginHeight);
        Graphics graph = Graphics.create(bmpOrigin);

        //Create a line of transparent pixels for later use
        int[] aEmptyLine = new int[nWidth];
        for(int x = 0; x < nWidth; x++)
            aEmptyLine[x] = 0x00000000;
        //Create two scaled bitmaps
        Bitmap[] bmpScaled = new Bitmap[2];
        for(int i = 0; i < 2; i++)
        {
            //Draw the bitmap on a white background first, then on a black background
            graph.setColor((i == 0) ? Color.WHITE : Color.BLACK);
            graph.fillRect(0, 0, nOriginWidth, nOriginHeight);
            graph.drawBitmap(0, 0, nOriginWidth, nOriginHeight, bmpSrc, 0, 0);

            //Create a new bitmap with the desired size
            bmpScaled[i] = new Bitmap(nWidth, nHeight);
            if(nAspectRatio == Bitmap.SCALE_TO_FIT)
            {
                //Set the alpha channel of all pixels to 0 to ensure transparency is
                //applied around the picture, if needed by the transformation
                for(int y = 0; y < nHeight; y++)
                    bmpScaled[i].setARGB(aEmptyLine, 0, nWidth, 0, y, nWidth, 1);
            }

            //Scale the bitmap
            bmpOrigin.scaleInto(bmpScaled[i], nFilterType, nAspectRatio);
        }

        //Prepare objects for final iteration
        Bitmap bmpFinal = bmpScaled[0];
        int[][] aPixelLine = new int[2][nWidth];

        //Iterate every line of the two scaled bitmaps
        for(int y = 0; y < nHeight; y++)
        {
            bmpScaled[0].getARGB(aPixelLine[0], 0, nWidth, 0, y, nWidth, 1);
            bmpScaled[1].getARGB(aPixelLine[1], 0, nWidth, 0, y, nWidth, 1);

            //Check every pixel one by one
            for(int x = 0; x < nWidth; x++)
            {
                //If the pixel was untouched (alpha channel still at 0), keep it transparent
                if(((aPixelLine[0][x] >> 24) & 0xff) == 0)
                    aPixelLine[0][x] = 0x00000000;
                else
                {
                    //Compute the alpha value based on the difference of intensity
                    //in the red channel
                    int nAlpha = ((aPixelLine[1][x] >> 16) & 0xff) -
                                    ((aPixelLine[0][x] >> 16) & 0xff) + 255;
                    if(nAlpha == 0)
                        aPixelLine[0][x] = 0x00000000; //Completely transparent
                    else if(nAlpha >= 255)
                        aPixelLine[0][x] |= 0xff000000; //Completely opaque
                    else
                    {
                        //Compute the value of the each channel one by one
                        int nRed = ((aPixelLine[0][x] >> 16 ) & 0xff);
                        int nGreen = ((aPixelLine[0][x] >> 8 ) & 0xff);
                        int nBlue = (aPixelLine[0][x] & 0xff);

                        nRed = (int)(255 + (255.0 * ((double)(nRed-255)/(double)nAlpha)));
                        nGreen = (int)(255 + (255.0 * ((double)(nGreen-255)/(double)nAlpha)));
                        nBlue = (int)(255 + (255.0 * ((double)(nBlue-255)/(double)nAlpha)));

                        if(nRed < 0) nRed = 0;
                        if(nGreen < 0) nGreen = 0;
                        if(nBlue < 0) nBlue = 0;
                        aPixelLine[0][x] = nBlue | (nGreen<<8) | (nRed<<16) | (nAlpha<<24);
                    }
                }
            }

            //Change the pixels of this line to their final value
            bmpFinal.setARGB(aPixelLine[0], 0, nWidth, 0, y, nWidth, 1);
        }
        return bmpFinal;
    }
View Full Code Here

    private class SetDisplayPic extends ScriptableFunctionBase {

        protected Object execute(Object thiz, Object[] args) throws Exception {
            final String displayPicURI = (String) args[0];
            final ScriptableFunction onComplete = (ScriptableFunction) args[1];
            final Bitmap displayPic = Util.requestBitmap(displayPicURI);
           
            Dispatcher.getInstance().dispatch(new DispatchableEvent(null) {
                protected void dispatch() {
                    boolean result;
                    try {
View Full Code Here

TOP

Related Classes of net.rim.device.api.system.Bitmap

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.