Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting external BITMAP images with Powerbuilder

Status
Not open for further replies.

RPatrick10

IS-IT--Management
Jan 25, 2006
8
0
0
US
I am looking to display images of our products within our database reports. I found the BITMAP() powerbuilder function. The problem is that I have 300+ images I would like to use. I can do it by using IF statements (such as...BITMAP(IF(product="001", "1.bmp", IF(product="002", "2.bmp", 0). For 300+ prodcuts this would take forever & be an extremely long calculation. Is there a way I can point to an external file with the bitmaps listed & use a different picture for each product? Thanks.
 
Do you store the bitmap filename somewhere with the data? (or is there some other way you can identify/specify what file goes with what record on the report?) If so you could add a hidden column to the report (lets call it 'bmpfilename') then add a computed field to the report with the expression:
bitmap(bmpfilename).

Matt

"Nature forges everything on the anvil of time
 
I currently have the Bitmaps stored in an external folder. I was using the full paths to find the bitmaps. The only way I can think of to get a different image for each row is to use the IF statements. I am looking for a way to specify what image goes with what row. I was hoping there was a way to do this externally & then have my application point to this external file. Thanks,
 
Creating a new column - as mbalent said - is the best way to do that. The user can choose an image to every product, and the report will show the image automatically with the expression:
Code:
bitmap(bmpfilename)

[bomb]
 
Ok, I am still a little confused. I will add a column named "bmpfilename". Is this a calculated or computed column? What does this column consist of? Is it a list of the bitmaps path? What enables the user to choose the image? Thanks for all you help guys. I am still a little new at this.
 
My solution involved two new columns. One is a blank string value returned from the database as in:

Code:
SELECT '' bmpfilename FROM TABLE WHERE ...
Alternatively this column could be retrieved from the DB if it contains the names of the bitmaps already.

Add this column to your datawindow but don't make it visible.

If you don't store the names of the bitmap files in your DB along with the other data, you will need to populate this column somehow with the name of the bitmap. Don't include the location of the files but that location will have to be in the path on the machine. (So PB can locate the files at runtime).

Add a second computed field (column) to the datawindow with the expression bitmap(bmpfilename) where 'bmpfilename' is the name of the first column you added.

At runtime this computed field will display the bitmap designated by 'bmpfilename'.

However, I see from your last message you say something about allowing the users to choose what image to display. This would require a slightly different approach.

Matt

"Nature forges everything on the anvil of time
 
OK, that explains it more, I will try it out. Thanks
 
Actually I do have another question. Will this work if I wanted to display different bitmaps for each product. LIke I said before we have well over 300 prodcuts & i wanted to display the image for each product, so I would have different images in each row. Thanks.
 
Yea, you have to create a new column into the table. The user will select the file of every product (using GetFileOpen) then you extract the path and file name and save it into the new column.

In the report, create a new compute field with the expression: bitmap(bmpfilename) and the report will display the image selected by the user.

It is a good idea to copy all the images into a shared folder so everyone will have access to the files.

That's one idea.

[bomb]
 
OK, you guys probably hate me by now. But what I am looking for...Say if I want to see the top 10 selling products of last month. WHen the report runs, i want it to automatically display the picture of all 10 products also. So it would be 10 pictures total, 1 in each row of the report. I can do it right now by using (Bitmap(IF(Product="001", "1.bmp", IF(Prodcut="002", "2.bmp"...etc. all the way up to product 10. There are over 300 products total so I would like to incorporate all 300 images somehow. I still not sure how to incorporate this into the hidden column. Would all 300 IF statments be included in there? What would be the exact way the code would look? I have used the PROFILEINT()function when entering data where the function points to an external text file I have. I have each item listed out in a list. FOr example. 001=product 1 002=product 2. When this is run, "Product 1" or "Product 2" is displayed next to these products. I was hoping i could do the same thing with bitmaps. Sorry to keep doing this, but thanks for you help still.
 
Code:
Bitmap(String(Long(Product)) + ".bmp")

With that code it will work but make sure the files have a standard:
Product File
001 --------> 1.bmp
002 --------> 2.bmp
003 --------> 3.bmp
...
010 --------> 10.bmp
011 --------> 11.bmp
...
101 --------> 101.bmp
...
999 --------> 999.bmp

Personally I'd create a new column on the table (named PathFile for example), put a open dialog box in the window of editing products so the user can choose the correct file, get the file and path and save in the column created. The files would be located in a shared folder so everyone have access to them.
The DataWindow would have this compute:

Code:
Bitmap(PathFile)

And the reporte would show the image selected by the user!

[bomb]
 
Do I just set that up as another text file like with the PROFILEINT()? Just by typing 0101=0101.bmp...for all products? I like the first code you listed, but I am not sure of what goes where "string" and "Long" are. Do I do BITMAP(PROFILEINT? Which part of that do I actually list the path for the bitmaps? Thanks again.
 
Ok, nevermind my last post. I can get it to work by using the following code.

Bitmap((Value_1) + ".bmp")

Value_1 is the name of the column listing my product numbers. In order for this to work for all products I would have to put all 300+ images in the root folder of the application on all servers we have. I would like to keep them in one location and be able to use the path for it. (for example: H:\ProductImages\). How could I do this? Thanks again.
 
Code:
Bitmap("H:\ProductImages\" + (Value_1) + ".bmp")

[bomb]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top