Creating a bitmap with scrolling

Finally, thanks to you guys, I finally cracked download of an image on the web and on display.

However, I have now ran into another problem I want to do the moving image, I found an example here

http://www.falseflag.com/BlackBerry/recipes/ScrollingImageRecipe.Java

However, when I use my existing bitmap to download and this code it fails.

I think, therefore, that is the fact that I download the data, but I'm not store data on the blackberry before you try to scroll the image.

My question is how to store the data?  Filestreaming or y at - it good technique caching that is available for the blackberry

Would appreciate your help

That's what I have so far

package PageSuite;

import java.io.*;
import javax.microedition.io.*;
import net.rim.device.api.system.*;
import net.rim.device.api.ui.*;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.container.*;
import net.rim.device.api.system.Bitmap;
import net.rim.device.api.ui.Graphics;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.component.Dialog;
import net.rim.device.api.ui.container.MainScreen;
import net.rim.device.api.util.DataBuffer;
import net.rim.device.api.util.ByteVector;
import net.rim.device.api.util.*;
import java.util.*;
import net.rim.device.api.i18n.*;

class ImageViewer extends MainScreen {

    private LabelField titleLabel;
    private BitmapField picField;
    public String urls;
    private EncodedImage jpegPic;
    private int finished = 0;

    ImageViewer(String URL) {    

        this.setTitle("Testing");
        titleLabel = new LabelField();

                finished = 0;

                LoadImager li = new LoadImager(URL);
                li.run();
                try
                {
                while (finished == 0)
                {
                     Thread.sleep(10);
                }
            }
            catch (Exception ex)
            {}

                this.add(picField);

    }

    private class LoadImager extends Thread {

         public LoadImager(String url) {
             urls = url;
         }

         public void run() {
             StreamConnection stream = null;
                InputStream in = null;
                synchronized(this)
                {
                try
                {
                stream = (StreamConnection)Connector.open(urls);
                in = stream.openInputStream();
                }
                catch(Exception e)
                {
                }
                }
                // Extract the data from the input stream.
                byte[] data = new byte[256];
                try
                {
                DataBuffer db = new DataBuffer();
                int chunk = 0;
                while ( -1 != (chunk = in.read(data)))
                {
                db.write(data, 0, chunk);
                }
                in.close();
                // Here is ur image in byte format.
                data = db.getArray();
                }
                catch(Exception e)
                {
                }

                EncodedImage jpegPic = EncodedImage.createEncodedImage(data, 0 , data.length);
                Bitmap bm = jpegPic.getBitmap();

                picField = new BitmapField(bm);
                finished = 1;

         }
     }

}

Hello

You can store the image in the file system of BB, and you can use it later. Look in the FileConnection API for more details.

Just a snippet of code.

FC = (FileConnection)Connector.open("file:///store/home/user/app/abcd.jpeg"); The device memory
If (!) FC. Exists())
{
FC. Create();
OS = fc.openOutputStream ();
}

OS. Write (rawData);

Tags: BlackBerry Developers

Similar Questions

  • How to create a no with scrolling background image

    I searched a lot on the forum and able to paint my background either by overriding methods of painting/paintBackground of the screen or the Manager. But the background is still floating, which means that when the screen scrolls down, the background goes back and white space appears.

    My question is, how do I make the fixed background image?

    Have you checked this post?

    http://supportforums.BlackBerry.com/T5/Java-development/about-background-images-and-layouts/m-p/2442...

    T

  • DM 3.1 how to create a Bitmap Index?

    How to create a bitmap with SQL Developer Data Modeler 3.1 index? In the relational model, the properties of the General table allows to enumerate the indexes of a table and to clarify some of their attributes as such as columns and uniqueness. In addition, the properties of the plain index allows more options to set the properties of the index. Unfortunately, I'm unable to find the right place to specify that an index is an index of bitmap.

    However, maker of data tend to support bitmap indexes because the generated DDL statements for a table with bitmap indices, which was initially imported into the data dictionary, have correct index bitmap creation instructions. However, when I compare all B tree index with bitmap index in Data Modeler I can't find an option that specifies the index type as bitmap. So, I would be very happy if someone could tell me how to create bitmap with Data Modeler 3.1 indices.

    Best regards

    Miikka

    Hey Miikka,

    physical model is the place where you can define the specifications of database objects created in the relational model. So you open the physical model and you can find the node index under the node for the related table - use dialog for index set to the index of the bitmap image.

    Philippe

  • & quot; News & quot; box with scroll bars

    Hello

    I would like to create a box with scroll bars to display reports that can be easily updated, similar to the one on the right side of the page on IDG.com. Can someone help me with this please?

    Unfortunately, we're stuck with Dreamweaver 4.0 for the time, so if there is a way to do it without putting on level and with my skills in programming very limited, that would be appreciated.

    Thank you!
    Ed

    This post answered on another forum...

    "eddddddddddd" wrote in message
    News:gm7lu5$AE8$1@forums. Macromedia.com...
    > Hi,.
    >
    > I would like to create a box with scrollbars to display news that
    > can
    > be easily updated, similar to the one on the right side of the page
    > on
    > http://www.idg.com. Can someone help me with this please?
    >
    > Unfortunately, we're stuck with Dreamweaver 4.0 for now, so if
    > there is a
    > how to do without to level, and with my very limited programming
    > skills,.
    > that would be appreciated.
    >
    > Thank you!
    > Ed
    >

  • List of the HorizontalFieldManager with scrolling focus problem

    Hello

    I'm doing a vertical list of horizontalfieldmanager with an icon and two text fields, but I'm having a problem when scrolling it. I used a nullField to manage focus. When I scroll to the top everything works well, but when I Ahmed to the bottom of the item appears on the edge of the screen.

    I guess that I did not understand how to manage the focusChange metodh and the metodh of the painting.

    All advice will be appreciated.

    Thank you, Andrea.

    //
        // Main screen for the application
        //
        private class MyMainScreen extends MainScreen
        {
            public MyMainScreen()
            {
                super(Manager.USE_ALL_WIDTH);
    
                for (int i = 0; i<20; i++) this.getMainManager().add(new PanelRow("off", "first text line", "second text line"));
            }
    
            private class PanelRow extends HorizontalFieldManager implements FocusChangeListener
            {
                private NullField nullField;
                private BitmapField icon;
                private ColorLabelField label1;
                private ColorLabelField label2;
    
                public PanelRow(String iconString, String label1String, String label2String)
                {
                    super(Manager.USE_ALL_WIDTH);
    
                    // Add null field
                    nullField = new NullField(NullField.FOCUSABLE);
                    nullField.setFocusListener(this);
                    super.add(nullField);
    
                    // Add bitmap
                    Bitmap offIcon = Bitmap.getBitmapResource("offButton.png");
                    icon = new BitmapField(offIcon, BitmapField.NON_FOCUSABLE | BitmapField.FIELD_LEFT);
                    super.add(icon);
    
                    // Add first and second text lines
                    VerticalFieldManager labelsVerticalManager = new VerticalFieldManager();
                    label1 = new ColorLabelField(label1String, LabelField.NON_FOCUSABLE | LabelField.FIELD_LEFT);
                    label2 = new ColorLabelField(label2String, LabelField.NON_FOCUSABLE | LabelField.FIELD_LEFT);
                    labelsVerticalManager.add(label1);
                    labelsVerticalManager.add(label2);
                    super.add(labelsVerticalManager);
                }
    
                public void focusChanged(Field field, int eventType)
                {
                    invalidate();
                }
    
                protected boolean navigationClick(int status, int time)
                {
                    fieldChangeNotify(FieldChangeListener.PROGRAMMATIC);
    
                    return true;
                }
    
                protected void paint(Graphics g)
                {
                    int oldBackground = g.getBackgroundColor();
    
                    if (nullField.isFocus())
                    {
                        g.setBackgroundColor(Color.CADETBLUE);
    
                        label1.setFontColor(Color.WHITE);
                        label2.setFontColor(Color.WHITE);
                    }
                    else
                    {
                        g.setBackgroundColor(Color.WHITE);
    
                        label1.setFontColor(Color.SLATEGRAY);
                        label2.setFontColor(Color.BLACK);
                    }
    
                    g.clear();
    
                    g.setBackgroundColor(oldBackground);
    
                    super.paint(g);
                }
            }
    
            //
            // Define a new colored labelfield class
            //
            public class ColorLabelField extends LabelField
            {
                public ColorLabelField(Object text, long style)
                {
                    super(text, style);
                }
    
                private int mFontColor = -1;
    
                public void setFontColor(int fontColor)
                {
                    mFontColor = fontColor;
                }
    
                protected void paint(Graphics graphics)
                {
                    if (-1 != mFontColor) graphics.setColor(mFontColor);
    
                    super.paint(graphics);
                }
            }
        }
    

    Then try to create your NullField with getFocusRect override: like this:

    nullField = new NullField(NullField.FOCUSABLE) {
      public void getFocusRect(XYRect rect) {
        getManager.getExtent(rect);
        rect.setLocation(0, 0);
      }
    };
    

    Paint won't help you - you must tell the system to the entire span developed in order to scroll properly. If the above fails, analyze your focusChanged eventType and make sure that your Manager is fully visible on the screen on FOCUS_GAINED. To do this, you need to use getManager () .getVerticalScroll () / getManager () .setVerticalScroll () as well as of your Manager and getHeight() getTop().

  • How half of the screen any part half scrollable and another screen with scrolling

    Hi all

    I am new to BB plz help me on this.

    Right now, the problem I'm facing is to make the left part of the screen fixed. For now, I wanted to show the list of n records to the right of the screen and wanted to show three buttons on the left side of the screen. When any user will scroll to display the records I want buttons remain fixed on the left side of the screen (No_Vertical_Scroll).

    Now I create a HorizontalFieldManager in which there are two verticalFieldManager so I can split the screen.

    I did the leftVerticalManager No_Vertical_Scroll and rightVerticalManager like VERTICAL_SCROLL, but when I scroll the screen both part began to scroll for the buttons on the left side mount are still not fixed.

    Thanks in advance

    I think so

    You can set the main screen is not first with scrolling

    Add a verticalFieldManager with fixed height half of the screen, the value of the scrollable

    then add a verticalFieldManger to the value of the scrollable

    Maybe it should work

  • Resizing of bitmaps with Graphics.drawTexturedPath - bad ratio

    Hello

    I used to resize bitmap images (to have the similar physical size on different phones) in my project with the following code - found in this thread:

    Without creating an encoded image bitmap image resizing

        public static Bitmap resizeBitmap(Bitmap image, int width, int height)
        {
            int imageWidth = image.getWidth();
            int imageHeight = image.getHeight();
    
            // Need an array (for RGB, with the size of original image)
            int rgb[] = new int[imageWidth * imageHeight];
    
            // Get the RGB array of image into "rgb"
            image.getARGB(rgb, 0, imageWidth, 0, 0, imageWidth, imageHeight);
    
            // Call to our function and obtain rgb2
            int rgb2[] = rescaleArray(rgb, imageWidth, imageHeight, width, height);
    
            // Create an image with that RGB array
            Bitmap temp2 = new Bitmap(width, height);
    
            temp2.setARGB(rgb2, 0, width, 0, 0, width, height);
    
            return temp2;
        }
    
        private static int[] rescaleArray(int[] ini, int x, int y, int x2, int y2)
        {
            int out[] = new int[x2*y2];
            for (int yy = 0; yy < y2; yy++)
            {
                int dy = yy * y / y2;
                for (int xx = 0; xx < x2; xx++)
                {
                    int dx = xx * x / x2;
                    out[(x2 * yy) + xx] = ini[(x * dy) + dx];
                }
            }
            return out;
        }
    

    My problem with the code was that it was quite slow - larger images would take almost a second (!) on the older phones (8830) scale.  It did not prevent UI - I have the code running in a separate Thread - but it has considerably delayed showing the image on the screen.

    Recently, I started to experiment with Graphics.drawTexturedPath and I really like this method.  However, I found a weird problem while reducing images.  For example, I need to put a picture of 48 x 48 up to 42 x 42.  The most important parameters for the scale are dux and dvy (of the four walk coordinates vector only these two are zero).  So now my code object looks like this:

    XYRect area = getExtent();
    // ourBgImage is the unscaled Bitmap - our background image
    int imageWidth = ourBgImage.getWidth();
    int imageHeight = ourBgImage.getHeight();
    int[] xPts = {0, 0, area.width - 1, area.width - 1};
    int[] yPts = {0, area.height - 1, area.height - 1, 0};
    int dux = (int) ((((long) imageWidth) << 16) / area.width);
    int dvy = (int) ((((long) imageHeight) << 16) / area.height);
    // Keep aspect ratio and make image fit fully
    dux = dvy = Math.max(dux, dvy);
    g.drawTexturedPath(xPts, yPts, null, null, 0, 0, dux, 0, 0, dvy, ourBgImage);
    

    which is a little shorter and much more fast-work (especially on older phones as 8830).

    However, the image is truncated on the right and down - looks like two pixels are missing on one of these two parties.  This was not the case with the old algorithm. I am specifying all the wrong settings?

    Final nail in the coffin of drawTexturedPath:

    I decided to check how drawTexturedPath resizes checkerboard (mainly the scale down).  And the results are pretty ugly - it seems to use the algorithm "nearest neighbour" without any means.  The project with which I tested it is attached.  Once you have it running, use Alt + move to shrink and Alt + down to stretch.  Observe the results.

    The decision is, of course, to remove this method and resize Bitmaps the old way

  • Is it possible to create a bitmap 'dynamic '?

    I need to create a bitmap "on the fly" with a text on this subject.

    Depending on the situation and the State of the application, I need to generate an image with text and perhaps a few images on this subject. The problem is that I do not really want to show this picture on the screen, so the image must be built "off screen" and not to the user.

    This generated image will not contain images of resources or a saved image or something like that, so

    I'll be writing the text on a colored background, maybe do some picture on it and then save this image as a bitmap.

    So I guess what I need to know is how can I go do a bitmap which we tell just contains "Hello World" on a black background?

    Is this possible?

    Thank you.

    Take a look at the net.rim.device.api.ui.Graphics class. Special attention to the static method Graphics.create.

  • Is it possible to create a form with text boxes of "adjustment" to the participants to answer the questions?

    Is it possible to create a form with text boxes of "adjustment" to the participants to answer the questions? Questions are open to everyone, so asking narrative responses.

    Hi landon39843319,

    You can have fields flowing / more dynamic in a PDF of LiveCycle Designer form, but not in an AcroForm (only created in Acrobat).  LiveCycle Designer is a program completely separated used for are delivered with each purchase Acrobat Acrobat XI has been release.  Now you must buy separately.  But LiveCycle Designer PDF forms are wrapped in a shell of PDF so that they will be displayed and can be filled in the free Acrobat Reader DC and earlier versions.

    If you do this in Acrobat with an AcroForm, you have as much information typed into a field that the user wants, but he's going to show everything on the screen.  Displays only the text that fits into the field, then a + sign will appear in the field to indicate that there is more text in this field, you can scroll down to read.  You can also set the automatic font size so that as more text is entered in the police becoming smaller and smaller to adjust the text, but that is usually not desirable for many forms.

    Hope this helps,

    Dimitri

    WindJack Solutions

    www.pdfscripting.com

  • Slider with scrolling thumbnails

    Is it possible within the Muse have a slider/Gallery with scrolling thumbnails? Currently I use a third party Gallery to achieve, but I prefer to stay within the Muse herself.

    You can try to use the compositions, click slide show in the composition.

    In the target composition container insert the slideshow and as game slides, create different slideshows for containers of different composition.

    It would have a similar effect.

    Thank you

    Sanjit

  • PROB WITH SCROLLING OF TEXT; EM DOES NOT

    I have problems with the scrolling text. I placed a large jpeg image. I want to create a scrollable text on it, so I made a layer for it. Also, I went to paste and onboard in the Panel preferences and changed in 1024px for the horizontal version. Now, I put the text on the Board of directors passed and with the same name, I also created a layer of Caontainer where I made a box on the active Board Indseign and put this layer where I created the image with the same name. Now when I save and go to the overview folio my scrolling text does not work.

    What I need to do something in overlays or something In Design

    Looks like you might be trying to do scrolling text in original, exceeded the way that we had to do in the first days of DPS.

    This link will take you to a step by step guide on the DPS help page:

    http://helpx.Adobe.com/Digital-Publishing-Suite/help/scrollable-frame-overlays.html

  • Connecting the frames with scroll

    Screen Shot 2013-09-06 at 12.54.32.png

    I've created a scenario planner of the wall as shown above. The month and the content below are in a floating frame that scrolls back and forth. The problem I have is that when I scroll down, I lose the months. So, I wanted to know if there is a way to connect the 2 frames with scroll separated? Really it pasted it and am sure that's not possible, so thought I would ask experts.

    Thank you very much

    Steve

    I'm sorry but I don't have time for a long answer. If you read my post above, once again, you will see that you need create two moving images.

    1. just below the month set to vertical content.

    2. one that contains the first one grouped with the months set horizontally.

    Try it and tell us.

  • Typeface is more heavy/more bold inside frames with scroll

    Text inside frames with scroll appears heavier on the ipad.

    Font is identical in InDesign DPS, obviously.

    See picture attached. Can be a little difficult to tell the difference with the screenshot.

    I put the text in the position box, top left. Using the commands "Cut" and "Paste inside" to create the scroll frame.

    In addition, I have an item multi-state of two States (box with bland gradient feathering), set to auto play slide show, at the bottom of the moving image.

    Both frame and a slide show with scrolling are on vector.

    scrollable_frame_font_wt.jpg

    Any help/advice appreciated - thank you!

    Bruce

    Thanks Bob!

    Knew that there must be a simple answer to this (accidentally built with older V20 folio).

  • Index table with scroll

    I'm new to Indesign; but I'm looking to do the following:

    I want to create a PDF file that has a table on the side left, that would be a clue with scrolling of the subjects for the PDF file. Is this possible in InDesign? And if so, how to create scrollable table?

    Oh, it's certainly doable in PDF files. They can not the Language Javascript and do anything.

    I don't think it's a good idea, however. Bookmark PDF interface provides the structure and a comfortable interface. If in doubt, invent your own user interface is almost always a bad idea... you will miss something subtle and annoys users and will not have the nice integration with the operating system, browser, or in this case, PDF Viewer, who they know.

    It seems that you can do with bookmarks, so you should, in my opinion.

    In addition, there are not exactly rich tools to develop the JavaScript in a PDF file. certainly InDesign isn't such a tool (so our Advisor in this forum is of limited use), and I'm not really sure Acrobat Pro is either.

  • I created a document with textedit, and now need to add a password

    I created a document with textedit, and now need to add a password to this document that exists.  Is it possible to do?

    I'm afraid that there is not.

Maybe you are looking for