IllegalArgumentException in drawbitmap

Hi all

I am struggling to explain an illegalargumentexception that occurs during a call to drawbitmap since in my routine of painting.

I have the settings and the call looks like:

graphics.drawBitmap (0, 0, 240, 149, image, 16, 107);

The image is a 256 x 256 square.

Can anyone offer a suggestion as to why this should raise an exception?

Thank you!

I discovered that the images back to me were not always the dimensions that I asked. Thank you for pushing me in the right direction!

Tags: BlackBerry Developers

Similar Questions

  • Graphics.ROP throws IllegalArgumentException

    I'm an IllegalArgumentException (with null backtrace and message) when I do the following in the paint for a custom field method:

    g.ROP (Graphics.ROP_SRCMONOEXPAND_COPY, x, y, FONT_CHAR_WIDTH, FONT_CHAR_HEIGHT, font_, left, top);

    However, the following works (though without the colorization, I want):

    g.drawBitmap (x, y, FONT_CHAR_WIDTH, FONT_CHAR_HEIGHT, font_, left, top);

    font_ is a Bitmap loaded from a custom PNG (a monospace font) file. I use the Eclipse plugin and a 4.5.0 Simulator. ROP() worked from 4.2 and 4.5 API documentation made no mention that he has changed since then. ROP_SRCMONOEXPAND_COPY is not obsolete, is it?

    Does anyone have insight into this? Thanks in advance.

    Never mind, you were right - the file PNG itself stores 1 bit per pixel, but for some reason Bitmap.getBitmapResource () that converts a bitmap with 16 bits per pixel. The documentation for Graphics.rop () does not indicate that there is a problem, and indeed it works when compiled with the 4.2 API on devices physical time 8830 and 9000. When I give a 1-bit Bitmap to Graphics.rop (), it works with ROP_SRCMONOEXPAND_COPY.

    RIM, please update the documentation of the JDE to tell API Graphics.rop () is no longer can use any image, and it will throw an IllegalArgumentException if he dislikes the Bitmap image, he is given.

  • IllegalArgumentException in PIMItem.getString (int, int)

    int[] intarray = cont.getFields();
    for(int x = 0; x < intarray.length; x++)
    {
        System.out.println(cont.getString(intarray[x],0));
    }
    

    This is just one example of code, but it throws the same exception is my real application.  Suite is a Contact object that I've initialized from the context object in the address book.  Whenever I get to the line getString, it throws an IllegalArgumentException for anything other than the constant of PIMItem.TEL despite the fact that other objects are not null.  I develop for the Blackberry 7290 with Handheld Software version 4.1 and JDE version 4.1.  Is there a reason that I'm getting this exception?

    EDIT: Sorry, Contact.TEL not PIMItem

    You don't want to read a string if it * is * a string.  Try something like:

    int[] intarray = cont.getFields();
    for(int x = 0; x < intarray.length; x++)
    {
        if (myPimList.getFieldDataType(intarray[x]) == PIMItem.STRING) {
            System.out.println(cont.getString(intarray[x],0));
        }
    }
    
  • Push registration: (Berr java.lang.IllegalArgumentException) network error

    Hello

    We try to get WebWorks push the work but are a problem with blackberry.push.openBISPushListener. The onRegister function returns a status of 1 (network error).

    The log file shows the following:

    11/9 10:00:54 W net.rim.blackberry.api.push - Berr java.lang.IllegalArgumentException
    11/9 10:00:21 a Contapp - PushDaemon is started.
    11/9 10:00:21 a Contapp - Register push application
    11/9 10:00:21 a Contapp - open BIS push listener
    

    This application is used to work so I wonder if something might have changed in the upgrade of the server push.

    The application code is the following:

    
    
    
        
    
    
        

    And the following push configuration in the config.xml file:

    
    
    
    
    
    
    
    
    
      BIS-B
      MDS
      TCP_WIFI
      TCP_CELLULAR
      WAP2
      WAP
    
    
    
      read_device_identifying_information
      access_shared
    
    

    It is all tested on a device 9300.

    Any ideas as to why we get this error?

    Thanks in advance for the help!

    Nick

    This issue should now be resolved, please let me know if you continue to have problems with the registration with the EVAL server.

  • ApplicationMessageFolderRegistry registerFolder IllegalArgumentException

    I have the same problem Visual as described in this post solved, however my way to get there is slightly different than in my opinion. To explain, I am trying to save a folder of messages for the purpose of issuing alerts and notifications on certain events. My app is, technically, neither demand nor a UIApplication - it is a top-level class who will then create one or the other according to the entry point. My background AEP monitor is an Application and my ASP UI is a UIApplication. In other words the main function is not in a class of each types.

    I need to create an application folder in which the background AEP monitor can send messages. The folder must be registered with the ASP of the UI so that it's what opens when the dossier is typed on the home screen. I get the IllegalArgumentException When calling ApplicationMessageFolderRegistry.registerFolder and I think it is because my main application is not strictly speaking a UIApplication.

    Can anyone confirm that it is the expected exception in this situation and what I might be able to do about this please? It will be difficult for the redesign of my application at this point... I'd like that there is another solution. Here is the code that generates the exception. What is strange, is that sometimes it seems to work ok, but sometimes it does not work and I then two icons of the application in the notification bar.

    ApplicationDescriptor uiAppDesc = null;
    
    int moduleHandle = CodeModuleManager.getModuleHandle("my_app_module_name");
    ApplicationDescriptor des[] = CodeModuleManager.getApplicationDescriptors(moduleHandle);
    for (int i = 0; i < des.length; i++)
    {
        String descName = des[i].getName();
        if (descName.equals("UI AEP Name"))
        {
            uiAppDesc = des[i];
        }
    }
    
    if (uiAppDesc == null)
    {
        Debug.Log("Could not find ApplicationDescriptor for UI App entry point", Debug.DBG_NOTIFICATIONS);
        return;
    }
    
    ApplicationFolderIntegrationConfig config = new   ApplicationFolderIntegrationConfig( false, true, uiAppDesc);
    
    //Register the ApplicationMessageFolder
    //ReadableListImpl source is available in the messagelistdemo.
    ApplicationMessageFolder folder = ApplicationMessageFolderRegistry.getInstance().getApplicationFolder(AppMain.APPLICATION_ID_LONG);
    if (folder == null)
    {
        folder = ApplicationMessageFolderRegistry.getInstance().registerFolder(
            AppMain.APPLICATION_ID_LONG, APPLICATION_MESSAGE_FOLDER_NAME, new ReadableListImpl(), config);
    }
    

    It seems I have fixed this problem. The solution was to place the call to my code above inside a new workable with invokeLater. I was using an executable elsewhere in the code, that's why the problem seemed to be intermittent.

    By comparing the two code sections was the only way I stumbled upon this fix. The document does not indicate that this could cause an IllegalArgumentException thrown so I wonder now how would I know otherwise. I don't know * why * this fixes it for me... any other comments welcome!

  • Blackberry Simulator running: IllegalArgumentException

    Hello

    Recently I had to reinstall Eclipse and I when I try to run the simulator of eclipse, I get this error:

    Cannot start the Simulator. Verify that this file exists.

    (java.lang.IllegalArgumentException: name of the executable integrated quote, divide the arguments)

    If I open the plugin file and run "fledge.exe" from there the Simulator opens. This was happening to anyone else?

    Thanks for your advice,

    Ben

    I ended up reinstalling Eclipse in "C:\Eclipse\" rather than "C:\Program Files\Eclipse\" because of the white space in "Program Files". Works fine now! @Nelvin I am sure that your solution works just as well.

    Thank you

    Ben

  • g.drawBitmap problem


    Try this.

     g.drawBitmap(0, 0, 50, Display.getHeight(), myBackground, 0, 0);
    

    And what is myBackbround.

    Look at this reference

    public void drawBitmap(int x,                       int y,                       int width,                       int height,                       Bitmap bitmap,                       int left,                       int top)
    
    Parameters:
    x -Leaves the edge of the region of destination.
    y -Top on board the destination region.
    width -Width of the destination region.
    height -Height of the destination region.
    bitmap -Bitmap to draw.
    left -Edge of the region within the bitmap to pull to the left.
    top -Top on the region within the bitmap to draw.
    ------------------------------------------------------------------------------------
    Kudo press to say thank you to the developer.
    Also, press accept it as a button when you got the Solution.
  • How to use graphics.drawBitmap

    I have the 10 * 15 bitmap.

    If I want to draw a Bitmap occuping full displaywidth and the height of the image, I can do using this image.

    I tried to use this, but I can't get the single image to the required width. Method is

    graphics.drawBitmap (10,20,340,image.getHeight (), image, 0, 0);

    Is it possible

    Respect of

    Rakesh shankar.

    rcmaniac25 is right. You need first to scale your bitmap to the desired width. You would like to use the following method to the scale of your bitmap in width:

    Bitmap resizeByWidth(Bitmap originalBitmap, int w) {
     double ratio = (double) originalBitmap.getWidth() / (double) w;
     int h = round((double) originalBitmap.getHeight() / ratio);
    
     Bitmap scaledBitmap = new Bitmap(w, h);
     originalBitmap.scaleInto(scaledBitmap, Bitmap.FILTER_BILINEAR);
     return scaledBitmap;
    }
    
    int round(double d) {
     return (int) Math.ceil(d);
    }
    
  • TextField + NumericTextFilter = IllegalArgumentException

    Hello

    I have a text field with a NumericTextFilter

    net.rim.device.api.ui.component.TextField t = new TextField();

    t.setFilter (new NumericTextFilter());

    Let me do not allow inserting non-numeric characters, instead, when I press on a tank that is not a number, I get an IllegalArgumentException. Can you tell me how I can solve this problem?

    Thanks in advance.

    Kind regards

    Gianni.

    So you say that when your username is centered on an EditField with this standard TextFilter in place, and they type an alphabetic characters, and not a numeric characters, your program gets an IllegalArgumentException?

    To be honest I find it hard to understand.  In all cases where use filters, the invalid keystrokes are ignored.

    What I think is happening, is that you are trying to fill this field with data, so that your setText (...) is failing in this way.  As your user, when you try to put data in this area should be matching the filter.

  • IllegalArgumentException in SQLiteDemo on CodeSigningKey (int, String)

    Hi all

    I am trying to run the SQLiteDemo on my BlackBerry Simulator (5.0) (using Eclipse plug-ins, JDE). The project will build without any problem. When I try to launch the project of the Simulator, however, I get an IllegalArgumentException on CodeSigningKey.get (int, String) on line 308 of CodeSigningKey.class (whose source is not found).

    I suppose it comes from the following line of code in SQLiteDemo.java:

    // Retrieve the code signing key for the XYZ key file
            CodeSigningKey codeSigningKey = CodeSigningKey.get(CodeModuleManager.getModuleHandle( "SQLiteDemo" ), "XYZ");
    

    The values of int, String at this stage are:

    moduleHandle = 0

    signerId = XYZ

    I use the XYZ.key provided in the BlackBerry sqlitedemo.zip. Anyone know why I get this error?

    Thank you!

    My project was not «enabled for BlackBerry»

  • ApplicationPermissionsManager get "object already exists" IllegalArgumentException

    I have the following code on a storm running OS 4.7:

    Permanent ApplicationPermissions = new ApplicationPermissions();

    perms.addPermission (ApplicationPermissions.PERMISSION_INTERNET);

    ApplicationPermissionsManager permMgr = ApplicationPermissionsManager.getInstance ();

    If (perms.difference (permMgr.getApplicationPermissions () .length! = 0) {}
    permMgr.invokePermissionsRequest (perms);
    }

    When I run this code the first time I install my application, invokePermissions() throws an IllegalArgumentException, and I see a pop error dialog box saying "the item already exists."  The application seems to work normally after that.  Y at - it something I do to cause this error, or is this a bug in BlackBerry OS?

    The fundamental problem was that I wonder the thing first authorizations in main() for CLDC app with multiple entry points.  Apparently the operating system does not support multiple applications at the same time.  The solution was to take an entry point and don't have this one do the permanent checks.

  • App not install on tour: 907/IllegalArgumentException

    I have a potential user who simply can not get my KeePassBB2 app to install on a Sprint 9630 Tour (4.7.1.40).  OTA, he gets a "907 invalid cod" and from the Office Manager, it becomes "a fatal error has occurred. in updating the software of your device Please try again. "In the system log, he sees:

    Name: IllegalArgumentException
    GUID: 9c3cd62e3320b498
    Time: July 20, 2009 23:04:34
    No detail message
    net_rim_cldc-7 (4A42F4E8)
    CodeModuleGroup

    0x898D
    net_rim_bb_browser_lib-1 (4A42FE06)
    ApplicationDownloadManager
    run
    0x17D
    net_rim_cldc-1 (4A42F4E8)
    Thread
    run

    0xB3F1

    The same combination of jad/COD (compiled under 4.2.1) installs and works fine on other devices of an 8700 to 9530.

    Anyone got any ideas?

    Looks like this same user has the same problem with Docs-To-Go.  Apparently the migration done one Assistant watch something upward when it was upgraded to the tour and removing migrated versions of the software and re - install from scratch, solved the problem.

  • Eception exception: java.lang.IllegalArgumentException 9800 simluator and device

    First of all, let me say that this forum has been very useful development councils, of the examples and answers to difficult questions.  Thank you.  But now I have a problem that I can not find a solution for or to understand.

    I created an application that listens to the calls and when the call is disconnected it displays a screen, allows entry and persists the results.  I developed in JDE 5.0.0.25 and it worked fine on the Simulator.  When I installed on a Torch 9800, I get "Eception exception: java.lang.IllegalArgumentException" when it tries to display the entry screen.  I downloaded and installed the ATT 6.0.0.246 for 9800 Simulator and traveled the code.  I get the same exception on the Simulator.  It seems that he fails once the code that creates the screen is executed and control is returned to the operating system.  The code to display the screen looks like

    {Synchronized (application.getEventLock ())}
    UI UiEngine is Ui.getUiEngine ();.
    ui.pushGlobalScreen (oEFDS, 10, UiEngine.GLOBAL_MODAL |) UiEngine.GLOBAL_SHOW_LOWER);

    If the questions are

    1. any ideas why it worked in version 5 and not 6? I thought developing in version 5 allow more devices run the application.

    2. is there something specific for the Torch 9800 that may be cause of tha?

    OK, I found the answer to this problem.  Guess I should have looked before asking for help.

    http://supportforums.BlackBerry.com/T5/Java-development/differences-between-V5-0-OS-and-V6-0-OS-for-...

  • question of drawbitmap

    I am doing a custom desktop like application blackberry maps (drag and zoom) except that I show my own images.  I can't drag the image around with drawbitmap but because of the high settings and left I can go only in two ways, i.e. If the top/left parameters are negative, I get an Exception of illegal Argument.

    What is the right way to go on this subject?  I thought to do the bitmap I show larger, but it seems that this is not a great way to do it because if they zoom back just a bit too far, or drag the image too far so I'll throw an exception.

    Even the MapField is implemented in this way, allowing you to verify that you're not outside its limit to zoom and pan, or it throws an Exception. You'll probably just to have to continue with what you do, but take controls in your methods to check you're not going too far.

  • Impossible to get drawBitmap to work

    Hello

    I read a lot of discussions and tutorials on drawBitmap to help, but I'm still stuck. When the user clicks on a button, I need to display one transparent png heap on another to create a display. I'm stuck to display only on the png, and fewer still those overlapping.

    I was hoping that someone could take a look at my code and tell me why my finger1.png is displayed. maintitle.PNG and buttons display as I want. Can anyone find where I have gone wrong?

    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 import. *;

    class Menu extends UiApplication
    {

    Private button1 As ButtonField.
    private ButtonField button2;
    private ButtonField button3;
    private ButtonField button4;

    Public Shared Sub main (String [] args)
    {
    App menu = New Menu();
    app.enterEventDispatcher ();
    }
       
    public Menu()
    {
    Screen MenuScreen = new MenuScreen();
    Bitmap objBitmap = Bitmap.getBitmapResource ("maintitle.png");
    BitmapField objHeader = new BitmapField (objBitmap);

    Button1 = new ButtonField ("button1") {}
    protected boolean trackwheelClick (int status, int time)
    {
    Screen2 MenuScreen = new MenuScreen();

    Bitmap img = Bitmap.getBitmapResource("images/finger1.png");
    Graphics g = screen2.getGraphics ();
    g.drawBitmap (0,0,18,18,img,0,0);
    Returns true;
                    
    }
    };

    Button2 = new ButtonField ("button2");
    Button3 = new ButtonField ("button3");
    Button4 = new ButtonField ("button4");
    HH FlowFieldManager = new FlowFieldManager();
    HH. Add (button1);
    HH. Add (button2);
    HH. Add (button3);
    HH. Add (button4);
    Screen.Add (objHeader);

    Screen.Add (HH);
    pushScreen (screen);

    }

    the final class private MenuScreen extends screen
    {

    {} public void close()
    Super.Close ();
    }
    }

    }

    Thank you very much.

    Kind regards

    Scott

    getGraphics() contains this warning in the documentation:

    The Graphics object returned by this call is no longer valid and should not be used after the end of the event to the current user interface.

    Note: We advise against using this method directly; Use invalidate() various methods instead. It can be used to draw directly on the screen when the screen contains no field.

    To work around this problem, you can preload rather this bitmap ("finger1") at the front and then call invalidate() on the screen and paint to paint the screen. How you decide to do it is to you, the lazy (and faster) way is to use a flag, the OO approach more implements a drawable send queue that is strong enough but obviously slower since you must browse (note that I didn't say synchronize .)

Maybe you are looking for