ImagXpress™ Professional v7 FAQ

Contact Support

This page contains frequently asked questions regarding using the ImagXpress 7 control along with sample code.

Q1What is the difference between ImagXpress Professional, Standard, View & Photo Editions?
Q2How can I determine if I have the latest version of a Pegasus control?
Q3How do I create a custom right mouse click menu?
Q4How do I create an image On-the-Fly?
Q5How do I display two views of the same image?
Q6How can I improve the quality of JPEG images?
Q7How do I handle errors in the ImagXpress control?
Q8How do I distribute my application (in .NET, Delphi, VB etc.)?
Q9How do I get a pointer to the DIB?
Q10How do I license an ImagXpress control on a webpage?
Q11How do I license ImagXpress when it is a component of a custom ActiveX control?
Q12How do I load and save an image with ImagXpress?
Q13How do I load multiple images with one ImagXpress control?
Q14How do I load or save a Multi-Page image?
Q15How do I make the items created by Draw methods change the image?
Q16How do I print an image from ImagXpress with PrintPro?
Q17How do I resize an image and preserve the Aspect Ratio?
Q18How do I retreive an image in Delphi stored in a BLOB database field and display in the ImagXpress control?
Q19How do I save memory when using ImagXpress?
Q20How do I select a region with a Rubberband?
Q21How do I update evaluation projects to registered projects?
Q22How do I use Aspect Ratio?
Q23How do I use graphic (Draw) methods?
Q24How do I use image processing methods?
Q25How do I use the Area method?
Q26How do I use the Merge method?
Q27How do I use the OleDragDrop event in Delphi?
Q28How do I use the Undo method?
Q29How do I work with NotateXpress' toolbar while ImagXpress' toolbar is visible?
Q30What DLL's do I need to distribute with my application?
Q31I tried to open a PDF in ImagXpress and got a -2 message. Why?

Q1: What is the difference between ImagXpress Professional, Standard, View & Photo Editions?
Please refer to the link listed below:
Comparison of ImagXpress Editions

Q2: How can I determine if I have the latest version of a Pegasus control?
Please download the PegConnect utility program from the following link: PegConnect
or reference the Latest Builds page.

Q3: How do I create a custom right mouse click menu?
Write code to define your menu:

IX1.MenuAddItem Menu_Context, 0, 100, 0, "Color:", 0, 0
IX1.MenuAddItem Menu_Context, 100, 110, 0, "White", &HFFFFFF, 0
IX1.MenuAddItem Menu_Context, 0, 200, 0, "Size:", 0, 0
IX1.MenuAddItem Menu_Context, 200, 210, 0, "Small", 1, 0
IX1.MenuAddItem Menu_Context, 0, 300, 0, "Type:", 0, 0
IX1.MenuAddItem Menu_Context, 300, 310, 0, "Line", 0, 0

Write the event handler to dispatch the work when the user makes a menu selection:

Sub IX1_MenuSelect (long long menuType, long tool, long topMenuID, long subMenuID, long user1, long user2)
if (menuType = MenuContext) then
  Select Case topMenuID
    Case 100 ' Color
      MyObj.Color = user1
    Case 200 ' Size
      MyObj.Size = user1
    Case 300 ' Type
      SelectCase subMenuID
      Case 310
        MyObj.DrawLine
      Case 320
        MyObj.DrawEllipse
      Case 330
        MyObj.DrawRect
      End Select
  End Select
end if
end sub

Q4: How do I create an image On-the-Fly?
You just call the CreateDIB method with the width, height, color-depth, and the color you want it to be to get your starting image. You can then do whatever you want to it, in particular with the draw methods.

Q5: How do I display two views of the same image?
Load the image into the first control, assign its ViewImageID to the second control's ViewImageID. Now the two views share the image.

IX7a.FileName = "a.gif"
IX7b.ViewImageID = IX7a.ViewImageID

Q6: How can I improve the quality of JPEG images?
When saving to a JPEG or ePIC file type you can change the compression / quality level using the SaveJPEGLumFactor, SaveJPEGChromFactor, and SaveJPEGSubSampling properties.

SaveJPEGLumFactor controls the brightness information, SaveJPEGChromFactor controls the color information, and SaveJPEGSubSampling affects color sharpness (to put it simply.)

You can also set the type of JPEG using the SaveJPEGProgressive and SaveJPEGGrayscale properties. See the help file for details.
For higher quality and lower compression, set SaveJPEGLumFactor and SaveJPEGChromFactor in the low teens and set SaveJPEGSubSampling to 1:1:1 compression.
For higher compression and lower quality, set SaveJPEGLumFactor and SaveJPEGChromFactor in the low 30's and set SaveJPEGSubSampling to 4:1:1 compression.
ImagXpress defaults to SaveJPEGChromFactor = 35, SaveJPEGLumFactor = 25, and SaveJPEGSubSampling = 4:1:1. I usually prefer SaveJPEGChromFactor = 22, SaveJPEGLumFactor = 22, and SaveJPEGSubSampling = 4:1:1 (or 1:1:1 for images containing text.)

Q7: How do I handle errors in the ImagXpress control?
After you do an operation on the ImagXpress control you should check the ImagError property if you think that it might fail.
To display the error if there is one then do something like this:

ImagXpress1.FileName = "c:\Images\Test.jpg"
IErr = ImagXpress1.ImagError
If IErr <> 0 Then MsgBox("Load Failed: Error #" & IErr)

ImagXpress will display an error message on the screen in some cases. You can disable this feature by setting the DisplayError property to False.

Q8: How do I distribute my application (in .NET, Delphi, VB etc.)?
PLEASE NOTE: You must have your unlock codes to distribute your application in the majority of the scenarios outlined below. If you do not have these please complete the form at: http://www.pegasusimaging.com/lostcodes.htm and the codes will be sent to you.

1) If you are using .NET as your development tool you must call the unlockPICImagXpress.PS_Unlock function and pass as the parameters the same 4 unlock codes that were received at the time of purchase.

For C# Developers:
Call the static PS_Unlock function in the class constructor BEFORE the generated call to InitializeComponent() as follows:

Public FormMain()
{
UnlockPICImagXpress.PS_Unlock(1234, 1234, 1234, 1234);
InitializeComponent();
}

For Visual Basic. NET Developers:
Call the static PS_Unlock function in the class constructor (i.e. New function) BEFORE the generated call to InitializeComponent () as follows:

Public Sub New ()
MyBase.New ()

UnlockPICImagXpress.PS_Unlock(1234, 1234, 1234, 1234)

IntializeComponent ()

End Sub

2) If you are using the Delphi VCL as your development tool you must declare the PS_Unlock function as outlined below:

procedure PS_Unlock(pw1, pw2, pw3, pw4: LongInt); stdcall external 'ImagXpr7.dll ';

begin

Application.Initialize;
PS_Unlock(123456789,123456789,987654321,12345);
Application.CreateForm(TForm1, Form1);
Application.Run;
end.

3) If you are using the ImagXpress COM object in VC++ as your development tool you must declare the PS_Unlock function as outlined below:

The ImagXpress COM Object contains a locking mechanism that does not permit you to distribute applications created with evaluation versions of ImagXpress. When you purchase ImagXpress, you are given a set of 4 numeric registration codes that is your individual password set for unlocking ImagXpress for distribution.

If you do not unlock ImagXpress, applications will not run on end user machines.

Before distributing an application, you must unlock ImagXpress.

IX_Open is included with ImagXpress to handle licensing for the COM Object. You can find IX_Open in the ImagXpress VCCOM\Include directory. In the IX_Open () function, locate the call to PS_Unlock(). Replace the four parameters in that call with the four registration codes you obtained when you registered ImagXpress. When you compile your project, ImagXpress should be unlocked meaning that you should no longer see the "Evaluation" message boxes.

4) If you are using the ImagXpress control as a COM object in VB you must declare the PS_Unlock function as outlined below:

  1) Add a reference to the ImagXpress 7 control via Project|References.

  2) Declare the PS_Unlock function as follows:

  Private Declare Sub ControlUnlock Lib "ImagXpr7" Alias "PS_Unlock" (ByVal pw1 As Long, ByVal pw2 As Long, ByVal pw3 As Long, ByVal pw4 As Long)

  3) Dim the ImagXpress control object:

  Dim ix As ImagXpr7.ImagXpress

  4) Call the unlock method:

  ControlUnlock 1234, 1234, 1234, 1234
  Set ix = New ImagXpr7.ImagXpress

5) If you are using the control within HTML you must obtain a web license string. This web license string is received from our sales department when the web license is purchased. The web license string is passed as the parameter to the IntegratorWeb method. Please refer to http://www.pegasusimaging.com/weblicfaq.htm for more information on using the control within a web environment.


Q9: How do I get a pointer to the DIB?
You can use the Windows API call GlobalLock to get a pointer to that data, and you should do a GlobalUnlock when you are done with it. The GlobalSize API will tell you how many bytes long the data is.

However, if you are working with the hDIB (handle to a Device Independent Bitmap) that you get from teh hDIB property instead of an hDIB that you get from the CopyDIB method, you should be aware that any operation that affects the image may cause the hDIB that ImagXpress had before the operation to become invalid.

It is recommended that you use the CopyDIB method to get your own hDIB, which you can examine or modify, and then you should either dispose of it using the GlobalFree API call or you can set the ImagXpress hDIB to that hDIB to have ImagXpress load that DIB.

If you save an image with SaveToBuffer=True then you can manipulate the buffer in the same way using the SaveBufferHandle property, except you would use the LoadBuffer method to load the image.

Q10: How do I license an ImagXpress control on a webpage?
Declare the ImagXpress object with these minimum required parameters. The correct values for ErrStr, ErrCode and ErrInfo will be properly generated for your machine and placed here by the ActiveX Control Pad. These values will change when switching from trial version to paid licensing.

<OBJECT ID="IX7" WIDTH="100%" HEIGHT="100%"
CLASSID=CLSID:6D3CF4F3-C2F3-46E7-A126-3E53102A6B91>
<PARAM NAME="ErrStr" VALUE="D9EAA52E5A263872E2EE64F9DC161476">
<PARAM NAME="ErrCode" VALUE="1016661769">
<PARAM NAME="ErrInfo" VALUE="-1652765689">
</OBJECT>
In scripting, call the IntegratorWeb method with the string you received from Pegasus when you licensed ImagXpress.

Sub window_OnLoad()
IX7.IntegratorWeb 'www.mysite.com\IX7Demo.htm?
2F009BA4D518CDAEB73D9BF40D552AE1'
End sub

Q11: How do I license ImagXpress when it is a component of a custom ActiveX control?
Add a reference to the PS_Unlock function as outlined below:

Private Declare Sub UnlockIX Lib "ImagXpr7" Alias "PS_Unlock" (ByVal pw1 As Long, ByVal pw2 As Long, ByVal pw3 As Long, ByVal pw4 As Long)

The choice of function name, "UnlockIX" in this case, is only significant for subsequent use.

Private Sub UserControl_Initialize()
  ' call the unlock function here and pass
  ' as the parameters the unlock codes you
  ' received when the product was purchased.
  'The values here are for demonstration purposes only.
  UnlockIX 1234,1234,1234,1234

  ' Now the embedded control is available for use.
  ImagXpress1.FileName = "C:\plane.jpg"
End Sub

Q12: How do I load and save an image with ImagXpress?
To load an image, set the FileName property to the path and filename you want to load. ImagXpress will look at the file extension to recognize the file type. If the file type is not one that ImagXpress knows it will try to automatically recognize the file type.

ImagXpress1.Filename = "C:\IMAGXPRESS\DOME.JPG"

To load an image from the internet set the FileName property to the full path and then in the AsyncProgress event look for Done = True or Error <> 0 to tell when it is done loading the image.

ImagXpress1.Filename = "http://YourSite.com/test.jpg"

To save an image, set the SaveFileName property and then call the SaveFile method. ImagXpress will automatically save the image as the type specified by the file extension if the SaveFileType property is set to 0 (FT_DEFAULT).

ImagXpress1.SaveFileName = "C:\IMAGXPRESS\XYZ.JPG"
ImagXpress1.SaveFile

Note that for some formats (JPEG, ePIC, TIFF, etc.) there are other properties that can be set that affect the way the file is saved. Check the SaveXXX properties to see if the format you are saving is one with other save options for that particular type.

Q13: How do I load multiple images with one ImagXpress control?
Simply assign the image's file name to the FileName property, change to another image buffer by setting the ProcessImageID to another number, and loading another file with FileName.

IX7.FileName = "a.gif" ' Buffer 500 by default
IX7.ProcessImageID = 501
IX7.FileName = "b.gif"
IX7.ProcessImageID = 502
IX7.FileName = "c.gif"

Then to change the view from one image buffer to another just change the ViewImageID to the desired buffer.

Sub cmdViewA_onClick()
  IX7.ViewImageID = 500
End Sub

Sub cmdViewB_onClick()
  IX7.ViewImageID = 501
End Sub

Sub cmdViewC_onClick()
  IX7.ViewImageID = 502
End Sub

Q14: How do I load or save a Multi-Page image?
The only multi-page image formats supported by ImagXpress are TIFF, PDF, ICO, DCX, and MO:DCA.

ImagXpress only supports creating multi-page images in ImagXpress Professional and Photo, while Professional, View, and Photo editions can read multi-page images. ImagXpress Standard will only read the first page of a multi-page TIFF.

To load a multi-page file you must first set the PageNbr property to the page you want to load and then set the FileName property to make it load that page. You can use the NumPages method to find out how many pages a file has. If you try and open a page in a file that does not exist then the ImagError property will get set to -21.

To save a multi-page file you must set the SaveMultiPage property to True. After that, when you save an image to a TIFF or DCX file, and a file with that name already exists, the current image will be appended as the last page.


Q15: How do I make the items created by Draw methods change the image?
There are three main reasons why this may not be happening properly:

1: You may have set PictureEnabled to False. (Set it to True to fix this.)
2: The image may be more than 16Mb uncompressed. (Beyond VB Picture Object max size.)
3: You are calling the DIBUpdate method. (Don't call this unless you do BitmapToDIB first.)

In either of the first two cases the problem is that there is no BMP in memory to do the draw methods on. If you check hBMP and it returns a 0 then that is the problem. If the problem is that PictureEnabled is set to False then the solution is simple (set it to True).

If the problem is that the image is really huge then you will have to use another trick. To get around that, you need a second hidden ImagXpress control that can be used to create a blank image with a color. This will then be used as the transparent color with the CreateDIB method. You can then draw on the hidden control and call BitmapToDIB to make what you drew part of the image.

We recommend checking your background color with DIBGetPixel to make sure that BitmapToDIB hasn't shifted your transparent color (which can happen in some color modes). Then use the Area and Merge methods on the main image to merge in what you drew on the hidden image using the transparent color you have in the hidden image.

Calling the DIBUpdate method redisplays the DIB that ImagXpress uses in memory. If you have something drawn on the image it is on the BMP that ImagXpress has in memory, and that does not become part of the DIB until you call the BitmapToDIB method. Calling DIBUpdate will refresh the BMP with any changes to the DIB (like a DIBSetPixel call).

Q16: How do I print an image from ImagXpress with PrintPro?
There are several ways to do this; the best is as follows:

Dim a As Integer
Dim b As Integer
PrintPRO1.hDIB = Xpress1.hDIB
PrintPRO1.ScaleMode = SCALE_Pixel
PrintPRO1.StartPrintDoc
a = PrintPRO1.ScaleWidth - PrintPRO1.LMargin
b = PrintPRO1.ScaleHeight - PrintPRO1.TMargin - PrintPRO1.BMargin
PrintPRO1.PrintDIB PrintPRO1.LMargin, PrintPRO1.TMargin, a, b, 0, 0, 0, 0, True
PrintPRO1.EndPrintDoc

The code listed below prints a multi-page TIFF image using ImagXpress and PrintPRO:

PrintPRO1.PrintDialog
PrintPRO1.StartPrintDoc
For counter = 1 To IX1.NumPages(IX1.FileName)
  IX1.PageNbr = counter
  IX1.FileName = IX1.FileName
  PrintPRO1.hDIB = IX1.hDIB
  a = PrintPRO1.ScaleWidth - 1 - PrintPRO1.LMargin
  b = PrintPRO1.ScaleHeight - 1 - PrintPRO1.Tmargin - PrintPRO1.BMargin
  PrintPRO1.PrintDIB PrintPRO1.LMargin, PrintPRO1.TMargin, a, b, 0, 0, 0, 0, True
  PrintPRO1.NewPage
Next counter
PrintPRO1.EndPrintDoc

Q17: How do I resize an image and preserve the Aspect Ratio?
If you want to resize the image data you should use the ResizeEx method. The AutoSize property and Zoom method only affect how the image is displayed on the screen and does not change the actual image data.

If you want to make the image scale to fit inside an area and keep its aspect ratio, you can use something like the following VB code:

If (ImgHgt > AreaHgt) Or (ImgWid > AreaWid) Then
  HScl = AreaHgt / ImgHgt
  WScl = AreaWid / ImgWid
  If WScl > HScl Then
    H = Int (ImgHgt * WScl)
    W = AreaWid
  Else
    H = AreaHgt
    W = Int (ImgWid * HScl)
  End If
  If H <= 0 Then H = 1
  If W <= 0 Then W = 1
Else
  W = ImgWid
  H = ImgHgt
End If
(Where ImgWid and ImgHgt are the width and height of the image, AreaWid and AreaHgt are the width and height you want to fit the imag e within, and W and H are the width and height that you will use to resize the image. All of this should be in pixels.)

You can use the IWidth property to get the width of the image in pixels and IHeight to get the height of the image in pixels.
If you just want to change the zoom scale you can do this:

If (ImgHgt > AreaHgt) Or (ImgWid > AreaWid) Then
  HScl = AreaHgt / ImgHgt
  WScl = AreaWid / ImgWid
  If WScl < HScl Then
    Ixp.Zoom WScl
  Else
    Ixp.Zoom HScl
  End If
Else
  Ixp.Zoom 1
End if
(Where Ixp is an ImagXpress control.)
This will scale the image to fit the control if the image is larger than the control, or show it at 100% scale if it is smaller than the control.
VB users should set the form's ScaleMode property to 3 (pixels) or convert the Width and Height of the control to pixels if they are going to use that as the area width and height.
In ImagXpress v7 you can also use the ZoomToFit method to do a zoom to width, height, or best fit instead of using the code above.

Q18: How do I retreive an image in Delphi stored in a BLOB database field and display in the ImagXpress control?
Please refer to this sample code:

Var
  Buffer : ^Byte;
  MemSize : Integer;
  Stream : TStream;

begin
  DataBaseConnection.Active := True;
  Stream := DataBaseConnection.CreateBlobStream(DataBaseConnection.FieldByName('Images') as TBlobField,bmread);
  Memsize := Stream.Size;
  Buffer := Allocmem(Memsize);
  Stream.Read(Buffer^,Memsize);

  //Load the image here
  Xpress1.LoadBufferPtr(Buffer^,Memsize);

end;

Q19: How do I save memory when using ImagXpress?
When you are not using the DrawXXX methods or the Picture property you should have PictureEnabled set to False. This will keep you from having two copies of the image in memory (one as a DIB and one as a BMP.)

Also, when loading a new image you may want to clear the previous image first because ImagXpress does not normally do that until the whole image has loaded successfully. To clear the image in the control you can set the hDIB property to 0.

If you are displaying the image scaled down you may want to resize the image to that size instead of using the Zoom method or AutoSize property.

You can also use the ColorDepth method to reduce the bit depth of the image. Use the UniqueColors method to count the colors in the image. For 2 colors use 1-bit color, 16 colors or less you can use 4-bit color, and for 256 colors or less you can use 8-bit color without damaging the image.

If you want an "undo" image, instead of using UndoEnabled you could save the image to memory in a compressed format like PNG and then load it back when you need it or use the GlobalFree Windows API call to free it from memory.

If you need to figure out approximately how many bytes an image is taking up in memory you can multiply the width (IWidth) times the height (IHeight) times the color depth (IBPP) and divide by 3.

Also, you may want to set the MultiTask property to true or set the ProgressEnabled property to True and put in the Progress event a DoEvents in VB (or an Application.ProcessMessages in Delphi, etc.) so that your application won't slow down other operations. You can also add a progress meter there to let the user know how far along ImagXpress is.

ImagXpress v7 now supports a new property called CompressInMemory that will have the control store the image in memory in a compressed mode as opposed to an uncompressed mode. Turning this on will slow down the ImagXpress control, so I would only recommend using this if you are using multiple ImagXpress controls at the same time.

Q20: How do I select a region with a Rubberband?
This requires you to programmatically handle mouse events. Start by activating the rubber band when the user first clicks the mouse:

Private Sub ImagXpress1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
  ' CLEAR ANY EXISTING RUBBER BANDING REGION
  ImagXpress1.RubberBand False, X, Y, False
  ' CONVERT X & Y TO PIXELS
  X = X / Screen.TwipsPerPixelX
  Y = Y / Screen.TwipsPerPixelY
  ' TURN THE RUBBER BANDING ON, SET THE STARTING POINT
  ImagXpress1.RubberBand True, X, Y, False
End Sub

Track the user's changes whenever he moves the mouse:

Private Sub ImagXpress1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  ' UPDATE THE RUBBER BAND
  X = X / Screen.TwipsPerPixelX
  Y = Y / Screen.TwipsPerPixelY
  ImagXpress1.RubberbandUpdate X, Y
End Sub

Do something with the region when the user lifts off the mouse:

Private Sub ImagXpress1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
  Dim xpos, ypos, w, h As Integer
  ' ANYTHING MAY NOW BE DONE WITH OR TO THE REGION
  ' THE USER HAS SELECTED. IN THIS EXAMPLE WE WILL
  ' COPY THE AREA TO ANOTHER CONTROL.
  ImagXpress2.hDib = ImagXpress1.CopyRubberbandDib
  ImagXpress2.ZoomToFit ZOOMFIT_BEST
  ' TURN THE RUBBER BAND OFF
  ImagXpress1.RubberBand False, X, Y, False
End Sub

Q21: How do I update evaluation projects to registered projects?
If you develop applications using the evaluation version of ImagXpress you must use the following procedure to update your applications after you legally register ImagXpress.

Register ImagXpress by entering the serial number and registration code supplied by Pegasus Imaging during the install process. Alternatively, you can register ImagXpress by clicking the Register Now button on the evaluation dialog box. The evaluation dialog box appears whenever an application using ImagXpress is run on a machine that has an evaluation version installed.

ImagXpress ActiveX Control
Open the your project with your development tool (Visual Basic or Delphi) and rebuild the EXE. The new registration information will be automatically incorporated in the new executable.

ImagXpress .NET Windows Forms Control
The ImagXpress .NET Windows Forms Control contains a locking mechanism that does not permit you to distribute applications created with evaluation versions of ImagXpress. When you register ImagXpress, you are given a set of 4 double word registration codes that is your individual password set that unlocks ImagXpress for distribution.

ImagXpress COM Object for VC++:
The ImagXpress COM Object contains a locking mechanism that does not permit you to distribute applications created with evaluation versions of ImagXpress. When you register ImagXpress, you are given a set of 4 double word registration codes that is your individual password set that unlocks ImagXpress for distribution.

ix7_open.CPP is included with ImagXpress to handle licensing for the COM Object. You can locate ix7_open.cpp in the ImagXpress VCCOM\Include directory. In the IX_Open function, locate the call to lpfnDllFunc1. Replace the four parameters in that call to the four registration codes that you obtained when you registered ImagXpress. When you compile your project, ImagXpress should be unlocked meaning that you should no longer see the "Evaluation" message boxes or the "Evaluation" stripe on images loaded into the ImagXpress component.

ImagXpress VCL for Delphi:
The ImagXpress VCL contains a locking mechanism that does not permit you to distribute applications created with evaluation versions of ImagXpress. When you register ImagXpress, you are given a set of 4 double word registration codes that is your individual password set that unlocks ImagXpress for distribution.

The VCL component file is ImagXpr7.pas which is located in the ImagXpress VCL directory. Load the component into Delphi. Search for the constructor TXpress.Create. The constructor contains a call to PS_Unlock. Replace the 4 parameters being passed to PS_Unlock with the 4 registration codes that you obtained when you registered ImagXpress. Reinstall the component. When you build or rebuild projects with the new component, ImagXpress should be unlocked meaning that you should no longer see the "Evaluation" message boxes or the "Evaluation" stripe on images loaded into the ImagXpress component.

Q22: How do I use Aspect Ratio?
There are two kinds of aspect ratio that you need to be aware of when working with 2D images; the image aspect ratio and the pixel aspect ratio.

The image aspect ratio is the ratio of the width of the image to the height of the image. It's important when resizing an image to keep this ratio as close to unchanged as possible or the image may become distorted.

The pixel aspect ratio is the shape of the pixels in the image. For computers this is normally square (1:1) or close to it depending on the monitor settings. For some video sources, however, the pixels may be slightly rectangular.

You can effectively change the pixel aspect ratio using the AspectX and AspectY properties. So, if you had an image that came from a video source where every other horizontal scan line was removed the image would have an aspect ratio of 2:1 because the pixels are twice as wide as they are tall. Setting AspectX to 2 and AspectY to 1 will cause the 2:1 image to be displayed properly.

This may be a little confusing, so you need to realize that you use AspectX and AspectY to set the pixel aspect ratio for the image to be displayed properly. AspectX and AspectY is not used to "counteract" the pixel aspect ratio. So, if the image appears to be distorted so that a square appears to be twice as wide as it is tall then you need to increase the AspectX to two to match that so the image will be displayed correctly.

Note that changing the pixel aspect ratio will change the displayed image aspect ratio though the actual image data is unchanged, but changing the image aspect ratio using one of the zoom or resize methods will not affect the pixel aspect ratio.

Finally, some image formats support storing aspect ratio information (BMP, TIFF, PNG) and they should be opened automatically at the correct aspect ratio if that information was set properly. You can use the IResX and IResY properties to set the DPI and aspect ratio information in your image for some formats. (See Also: "IResX" & "IResY") Though many other image viewing programs will not use these values but will just display at a one-to-one aspect.

Q23: How do I use graphic (Draw) methods?
The ImagXpress control has graphic drawing methods that let you draw lines and shapes inside the control. Note that graphics are drawn to the control’s display bitmap but not to the control’s DIB. Use the BitmapToDIB method to make the drawing elements part of the actual image. The control must have a bitmap in order for the graphic methods to draw. Note also that since the graphics are not drawn into the DIB, they will not be saved as part of the image when the SaveFile method is invoked. The Annotate sample demonstrates a technique to draw and save annotations into an image.

The following properties and methods are used to draw graphics:

  DrawFillColor — Returns or sets the color used to fill in circles, boxes and polygons created with the DrawCircle, DrawLine, and DrawPolygon graphics methods.
  DrawFillStyle — Returns or sets the pattern used to fill circles and boxes created with the DrawCircle, DrawLine and DrawPolygon graphics methods.
  DrawMode — Returns or sets a value that determines the appearance of output from graphics methods.
  DrawStyle — Returns or sets a value that determines the line style for output from graphics methods.
  DrawWidth — Returns or sets the line width for output from graphics methods.
  DrawLine — Draws lines and rectangles on an image.
  DrawCurve — Draws a Bezier curve on an image.
  DrawCircle — Draws a circle or ellipse on an image.
  DrawPolygon — Draws a 2-6 sided polygon on an image.
  DrawRoundRect — Draws a rectangle with rounded corners on an image.
  DrawArc — Draws an arc on an image.
  DrawPie — Draws a pie-shaped wedge on an image.
  DrawTextString — Draws text on an image.

Q24: How do I use image processing methods?
ImagXpress includes a rich suite of methods that make it easy to perform sophisticated image processing functions. The following Visual Basic source code shows how easy it is to load an image and sharpen it.

ImagXpress1.Filename = "C:\IMAGXPRESS\DOME.JPG"
ImagXpress1.Sharpen 5

The Sharpen method has one parameter, Sharpen Intensity. Sharpen Intensity can be set to values 1-10. Higher values provide more intense sharpening. Lower values provide less intense sharpening. The IPSharpenI property is a read-only property that is set to the Sharpen Intensity when the Sharpen Method is invoked. The IPSharpenI property lets you determine what the sharpen intensity was the last time the Sharpen method was invoked.

This example is provided to show how a typical image processing method is invoked. A complete list of methods is provided in Control Methods.

Q25: How do I use the Area method?
The Area method allows you to define a specific rectangular area inside the image that you want to alter. The Area method takes the following parameters: Enabled, X, Y, Width and Height. X and Y specify the top left position of the area in pixels. Width and Height specify the width and height in pixels of the area. When Enabled is True, image processing occurs within the specified area; when Enabled is False, image processing occurs within the entire image.

The following Visual Basic source code embosses an area 50 pixels high by 40 pixels wide, 10 pixels from the top and 20 pixels from the left of the image.

ImagXpress1.Area True, 20,10,40,50
ImagXpress1.Emboss
ImagXpress1.Area False ' Disable Area processing

If the specified area is too large to fit within the image, the rectangular area is automatically cropped. If the X or Y parameters are larger than the image's width or height, then Area is disabled.

Q26: How do I use the Merge method?
The Merge method is one of ImagXpress' most powerful image composition tools. The Merge method allows you to superimpose an image on an existing image. The Merge method has incredible flexibility and an abundance of features including the ability to define a merge area on an existing image, varying the percent of the merge, doing gradient merges with complete control over the gradient percentages, additive merges, subtractive merges, merging only lighter or darker pixels and transparent merges. Additionally, the merged image can be resized, cropped or tiled.

The Merge method merges the image loaded using the Picture or FileName properties with the current DIB. Using the Picture property, you can merge any image from any control that supports a standard Picture property. For example you can superimpose text on the current DIB using an image created by the Pegasus FXTools FXLabel control.

Detailed descriptions of the Merge method's parameters are found in the "Methods" section of the Help File.

Q27: How do I use the OleDragDrop event in Delphi?
You need to add a call to OleInitialize(nil) in the FormCreate event and a call to OleUninitialize in the FormDestroy event.

Q28: How do I use the Undo method?
One of the powerful features in ImagXpress is the ability to undo the action of a method. To enable the undo feature, set the UndoEnabled property to True prior to performing the image processing method. When UndoEnabled is True and an image processing method is invoked, the current DIB is copied to an undo DIB, and the current DIB is replaced with the altered DIB that the image processing method creates. To undo the method, simply invoke the Undo method. When the Undo method is invoked and the undo DIB exists, the current DIB is replaced by the undo DIB thus restoring the image to its original state. Note that when UndoEnabled is True, additional memory is required to store the undo DIB. Setting UndoEnabled False deletes the current undo DIB if one exists.

You can access the ImagXpress DIBs by using the hDIB and hDIBUndo properties. hDIB returns the window handle to the current DIB and hDIBUndo returns the window handle to the undo DIB. A value of zero indicates that a DIB does not exist.

Q29: How do I work with NotateXpress' toolbar while ImagXpress' toolbar is visible?
It is common to have NotateXpress' toolbar visible while ImagXpress' toolbar is also visible. If ImagXpress' toolbar is currently set to a tool other than the pointer (Tool_none) the NotateXpress toolbar tools will not activate.

Inform the user to set the ImagXpress tool to the pointer to be able to use the NotateXpress toolbar. A strongly worded tooltip for the pointer arrow is a good measure.

Q30: What DLL's do I need to distribute with my application?
For .NET Windows Forms Applications:
PegasusImaging.WinForms.ImagXpress7.dll

For All Other Applications:
ImagXpr7.dll - ImagXpress ActiveX Control
ImagX7.dll - ImagXpress support DLL
ImagXR7.dll - ImagXpress Resource DLL
ImagXRA7.dll - ImagXpress Resource DLL
TWNLIB4.DLL - TwainPRO DLL (only required for applications using TWAIN)

You must also distribute STDOLE2.TLB and OLEAUT32.DLL that are Microsoft support files. These must be registered prior to registering ImagXpr7.dll.

If you are using the ImagXpress COM component, it needs to be registered after it is installed. Make sure that your installation program registers the ImagXpr7.dll before you run your application.

Q31: I tried to open a PDF in ImagXpress and got a -2 message. Why?
ImagXpress supports a subset of PDFs. If you want full Adobe PDF Support you will need to add on the PDFXpress toolkit. ImagXpress will save b&w and color images to PDF, and will open up the PDFs it creates. Most other PDFs have non-image data inside them so ImagXpress will not open these. PDFXpress is available as an add on to ImagXpress for a discount.


Sitemap | © 2008 Pegasus Imaging Corporation. All Rights Reserved. | Privacy Statement.