473,468 Members | 1,294 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Bitmap Object - any special way to access it needed?

153 New Member
Hi all,

If i have a class - Product, it has 2 fields, String name, and Bitmap productImage. If I try to access the bitmap from another class like Bitmap b = p.productImage; I get null (i have tried many different ways - directly accessing or via a getter method) but if i try to access the string variable of the object it's fine. i know the bitmap has been created. Do i have to convert the bitmap into something else? or is my way of doing it correct?

Please hlp, i'm going out of my mind with this nullpionterexception.
Aug 22 '09 #1
3 1598
Markus
6,050 Recognized Expert Expert
@brendanmcdonagh
Seeing the code I may be able to spot an error; nothing jumps out at me from your description.

Mark.
Aug 22 '09 #2
brendanmcdonagh
153 New Member
There's a bit of it Marcus, I have been programming a blackberry app talking to a server. It it Java though, let me know if you would be willing to help me out, I qouldn't like to just post 2 1/2 classes without your ask me to. Here' the method that fills my list

Expand|Select|Wrap|Line Numbers
  1. public void drawListRow(ListField listField, net.rim.device.api.ui.Graphics g, int index, int y, int width) 
  2.    {
  3.    Product[] data;
  4.  
  5.     Product p = (Product) get(listField, index);
  6.  
  7.  
  8.         int ypos = y + UPPER_MARGIN;
  9.         int xpos = TEXT_MARGIN;
  10.  
  11.         String str1 = "line 1";
  12.  
  13.         String str2 = "line 2";
  14.  
  15.         Log.info("tdrawrow" + vector.size());
  16.  
  17.         //Product p = (Product)vector.elementAt(0);
  18.         this.productId = p.productId;
  19.     this.productName = p.productName;
  20.     this.productPrice = p.productPrice;
  21.     this.productOffer = p.productOffer;
  22.     this.productOfferValidity = p.productOfferValidity;
  23.  
  24.     if(p.getProductImagePath() != null)
  25.     {
  26.     try
  27.     {
  28.     try
  29.     {
  30.     b = p.productImage;
  31.     this.productImagePath = p.getProductImagePath();
  32.     Log.info("This is productimage" + productImagePath);
  33.  
  34.     }
  35.     catch(Exception jjj)
  36.     {
  37.     Log.info("Error tttt" + jjj);
  38.     }
  39.  
  40.  
  41.     int indent = 20;
  42.  
  43.     Log.info("b != null");
  44.     g.drawBitmap(0, y, 16, 16, b, 0, 1);
  45.     Log.info("drawn");
  46.  
  47.         g.drawText(productName, indent, y, DrawStyle.ELLIPSIS, width - indent);
  48.         Log.info("drawn text");
  49.     }
  50.  
  51.     catch(Exception tt)
  52.     {
  53.         Log.info("This is productimage error" + tt);
  54.          int indent = 0;
  55.         g.drawText(productName, indent, y, DrawStyle.ELLIPSIS, width - indent);
  56.     }
  57. }
  58.     this.productRating = p.productRating;
  59.     this.productQuantity = p.productQuantity;
  60.  
  61.  
  62.     Log.info("End of method");
  63.     }
  64.  
  65.     public Object get(ListField listField, int index) {
  66.        return vector.elementAt(index);
  67.     }
  68.  
  69.     public int getPreferredWidth(ListField listField) {
  70.         return getWidth();
  71.     }
  72.  
  73.     public int indexOfList(ListField listField, String prefix, int start) {
  74.         return getSelectedIndex();
  75.     }
  76.  
  77.  
  78.  
  79.  
  80.  
  81. }
Let me know if you want to see product, product creates the image from a utils class. It works when i just show the image in product class itself.

p.s. My two variable class was hypothertical, there are string variables for name, price, imagepath, offers, offer validity, etc and then the bitmap variable.
Aug 22 '09 #3
JosAH
11,448 Recognized Expert MVP
@brendanmcdonagh
There is nothing special about a Bitmap or any other type: if a field of that type is reachable from outside (e.g. it is a 'public' field) it is either null both inside and outside that particular object that holds the field or it isn't. Something else is wrong in your code. System.out.println( ... ) sprinkled in at strategic places is your friend here.

kind regards,

Jos
Aug 23 '09 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: DrUg13 | last post by:
In java, this seems so easy. You need a new object Object test = new Object() gives me exactly what I want. could someone please help me understand the different ways to do the same thing in...
5
by: Erwin | last post by:
At the moment I'm using a report which contains an indicator to show if a Service group of the company isn't working well or is working perfectly. This indicator is a "*" which looks like a traffic...
2
by: deko | last post by:
I have a table that contains a bunch of pictures. When the user selects a particular image in a form, I need a way to extract the selected bitmap image (stored in an OLE Object table field) to the...
7
by: Dennis | last post by:
I am trying to implement drawing on a bitmap and using bitblt to transfer it to the control graphics object in the paint event. It seems to draw on the bitmap ok but doesn't get transferred to the...
0
by: Travis Oliphant | last post by:
This post is to gather feedback from the wider community on PEP 357. It is nearing the acceptance stage and has previously been discussed on python-dev. This is a chance for the wider Python...
15
by: Hamed | last post by:
Have I posted the message to wrong newsgroup? Or Does the question is so much strage? Would someone please kindly direct me to a true newsgroup or resource? Best Regards Hamed
6
by: Dave Harvey | last post by:
I have developed a standard .NET control which displays medical images and works fine in applications, but increasingly, my customers are wishing to use it in an ASP.NET environment, so I am...
6
by: \Frank\ | last post by:
I trying to learn what a Bitmap is. Not a Managed Bitmap Object but one that, for example, comes from the clipboard with CF_BITMAP. I'm guessing that a CompatableBitmap is an array of indices...
1
by: =?Utf-8?B?ZWRkeWN0YW0=?= | last post by:
When creating a Bitmap object in C# with Bitmap temp = new Bitmap("(filename here)"; What is put into memory? Is it just the bitmap info header or is the entire bitmap loaded into memory? If it...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.