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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Converting Pixels to DDUs

Status
Not open for further replies.

thegorb

Programmer
Apr 11, 2003
3
US
Hello folks,

I am in the process of writing my first Aspect script which needs to do the following:

1. Screen scrape an item number off the terminal screen.
2. Locate a matching bitmap file.
3. Display found bitmap in a window until closed by user.
Specs require that the image pop into a separate window which is sized to the specific image.

I have accomplished 1 & 2. I have done 3 to the point where I know the image height and width.

If I am reading the Aspect docs correctly, it seems I need to use a diaglogbox to get the image in a separate window as uwincreate occupies a portion of the terminal window.

Dialogboxes are sized based on DDUs rather that pixels while my window size needs to be based on pixels.

Question 1: Am I interpreting the documentation correctly?
Question 2: How can the pixels be converted to DDUs to size the popup window correctly.

Thanks in advance,
Graydon
 
You did read the documentation in the same way I understood it, but I am now wondering if it is correct. I displayed a bitmap in a dialogbox and made the width and height of the bitmap in the dialogbox definition the size of the image in pixels. When I opened the image in Paint and displayed it next to my dialogbox, the images looked identical in size to me.

One way to find the size of the image in question is to open it in Paint and select the Image | Attributes menu item (this was on NT and may be slightly different on other platforms).


aspect@aspectscripting.com
 
Hi Knob,

Thanks for the reply.

Yes, I agree that the bitmap command is in pixels and does display the image the correct size.

It is the size of my dialog box that is 'way off. As the images are not a standard size, I either get a cropped image or white space along the right/bottom of the diaglog box.

I am looking for a way to convert the pixels to DDUs to size the dialog box to fit the image.

Since User Windows can be sized in pixels, I am willing to use a User Window if it can be moved outside the terminal window area by the user.

Regards,
Graydon
 
Sorry, I misread your message. Unfortunately, I am not aware of a formula to convert between DBUs and pixels. The best I can offer (if you are displaying the same set of bitmaps) is to manually determine the optimum size of the dialog for each bitmap that would be displayed, then adjust the dialogbox for each bitmap (meaning you would need a separate dialogbox for each bitmap of a different size). I tried using the Dialog Editor that ships with Procomm to design the dialogbox, but wasn't able to do this well due to the pixels/DBU problem. What you can do is create a new dialog in the Dialog Editor, add the bitmap (Controls | Bitmap menu item), right click the BMP graphic, select Properties, click the Constant radiobutton, browse for the bitmap, then move the BMP graphic to the upper left of the dialog. Once you've done that, save the bitmap to a .WUD file and edit the .WUD file (it's a text file) so that the height and width value of the bitmap is correct. Once you've done that, open the .WUD file in the Dialog Editor again and resize the dialog down to the smallest possible size it will let you. However, this will not be as small as it needs to be if you open this dialog via a script (due to DBUs not being equivalent to pixels). However, it will get you close and you can then manually edit the height and width values of the dialogbox itself to eliminate the extra space.


Unfortunately, uwincreate is not an option since the User Window contents are displayed in the terminal window instead of a separate window (like the dialogbox command).


aspect@aspectscripting.com
 
Hi Knob,

Thanks for the clarification, it is much appreciated.

Each .bmp file contains the picture pixel width in bytes 19-22 and height in bytes 23-26.

What I will do is set up 4 'optimum' dialog box sizes in DDUs then display in one of them dependent on the image size in pixels.

Granted, the majority will have a bit of white space along the right and/or bottom but I should be able to minimize it. One works with what One gots and this method is certainly better than no images at all.

I believe all our procomm terminals are set to use the PCPlus437 font, so if I get too much flak from higher up over this method, I may be able to work out an actual algorithm of Pixels to DDUs based on that one font. If so then I will pass it along.

Regards,
Graydon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top