run-time error

ImageMagickObject is a Windows COM+ interface to ImageMagick. COM+, Visual Basic, and Delphi users should post to this discussion group.
Post Reply
allegfede

run-time error

Post by allegfede »

Hello, here is my piece of code:

Code: Select all

Public Function ResizeImage(Style As Integer) As Boolean
Dim OriginalX As Integer
Dim OriginalY As Integer

Dim IMG As New ImageMagickObject.MagickImage    'carica e crea l'oggetto Image Magic
Dim BMP, JPN, Result As String                  'NOTA: i file BMP devono essere in una variabile BMP e quelli JPG in una JPN

Dim DestinationRes As String

    BMP = "c:\desktop.bmp"   'existing image from a screen-capture routine
    JPN = "c:\resize.jpg"
    
    OriginalX = Screen.Width \ Screen.TwipsPerPixelX    'detect resolution of the screen-captured image
    OriginalY = Screen.Height \ Screen.TwipsPerPixelY
    
    Select Case Style      'detect the type of resize the user wishes
        Case 0  '640X480
            DestinationRes = "640X480"
        Case 1  '800x600
            DestinationRes = "800x600"
        Case 2  '1024x768
            DestinationRes = "1024x768"
        Case 3  '1280x1024
            DestinationRes = "1280x1024"
        Case 4
            DestinationRes = OriginalX & "x" & OriginalY
    End Select
    
    Result = IMG.Convert("-resize", DestinationRes, BMP, JPN)
    
    MsgBox Result
    ResizeImage = True
    
    Set IMG = Nothing
End Function
but this result in a: runtime error '-2147418113 (8000ffff)'
with this (italian) description: Metodo 'Convert' dell'oggetto 'IMagickImage' non riuscito
witch is somethin' like: 'Convert' method of object 'IMagickImage' failed (sorry for the poor traslation ;-) )

Any hint of what could happen?

PS: I'm using STATIC ImageMagic version on a Visual Basic 6 (vb6) enviroment (on win XP home machine).

PPS: This command line works great: convert -resize "800x600" c:\desktop.bmp c:\destination.jpg
allegfede

Re: run-time error

Post by allegfede »

I changed this line on code:

Code: Select all

    Result = IMG.Convert("-resize", """" & DestinationRes & """", BMP, JPN)
because I tought I need this string to be passed to IMAGE MAGICK "800x600", nor the simple 800x600 (withou the " character) ...

.... but no way to let it work ... still runtime error
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Re: run-time error

Post by el_supremo »

If I remember correctly, Basic uses the backslash as an escape character so you need to escape the backslashes in the filenames.
Try this:

Code: Select all

    BMP = "c:\\desktop.bmp"   'existing image from a screen-capture routine
    JPN = "c:\\resize.jpg"
Pete
Sorry, my ISP shutdown all personal webspace so my MagickWand Examples in C is offline.
See my message in this topic for a link to a zip of all the files.
allegfede

Re: run-time error

Post by allegfede »

no way.

I tryied the c:\\filename metod, but still gives an error.

Now I use to fire a shell command with short path names (before I asked user to point ImageMagick installation folder):

Code: Select all

   
    BMP = (App.Path & "\desktop.bmp")   'segna quale e' l'immagine BITMAP d'origine
    JPN = App.Path & "\resize.jpg"  'e quella JPEG finale

    Set DosFolder = FS.GetFolder(FS.GetParentFolderName(BMP))
    BMP = DosFolder.ShortPath & "\desktop.bmp"
    JPN = DosFolder.ShortPath & "\resize.jpg"
    
    Set DosFolder = FS.GetFolder(FS.GetParentFolderName(IM_Path))
    IM_Path = DosFolder.ShortPath & "\convert.exe"
    
    Shell IM_Path & " -resize """ & DestinationRes & """ " & BMP & " " & JPN, vbMinimizedFocus

no one have a more elegant way?

Do I need to install ImaeMagic even if I use the DLL on my apps?

Thanks
Post Reply