0

在 VB.NET 中应该如何正确运行 imagemagick 转换函数?

我试过明确命名每个参数

    Public Magick As ImageMagickObject.MagickImage

    Dim s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11 As String

    If IsDBNull(FromImage) Then s1 = "" Else s1 = CStr(FromImage)
    If IsDBNull(Rotate1) Then s2 = "" Else s2 = CStr(FromImage)
    If IsDBNull(Rotate2) Then s3 = "" Else s3 = CStr(FromImage)
    If IsDBNull(Resize1) Then s4 = "" Else s4 = CStr(FromImage)
    If IsDBNull(Resize2) Then s5 = "" Else s5 = CStr(FromImage)
    If IsDBNull(Extra_Imagemagick_settings) Then s6 = "" Else s6 = CStr(FromImage)
    If IsDBNull(Alpha1) Then s7 = "" Else s7 = CStr(FromImage)
    If IsDBNull(Alpha2) Then s8 = "" Else s8 = CStr(FromImage)
    If IsDBNull(Alpha3) Then s9 = "" Else s9 = CStr(FromImage)
    If IsDBNull(Alpha4) Then s10 = "" Else s10 = CStr(FromImage)
    If IsDBNull(ToImage) Then s11 = "" Else s11 = CStr(FromImage)
    Dim params As String() = {s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11}
    Magick.Convert(params)

我尝试创建一个数组:

    Dim params As object() = {FromImage, Rotate1, Rotate2, Resize1, Resize2, Extra_Imagemagick_settings, Alpha1, Alpha2, Alpha3, Alpha4, ToImage}

    params = New Object()
    ReDim params(20)
    params(0) = CStr(FromImage)
    params(1) = Rotate1
    params(2) = Rotate2
    params(3) = Resize1
    params(4) = Resize2
    params(5) = Extra_Imagemagick_settings
    params(6) = Alpha1
    params(7) = Alpha2
    params(8) = Alpha3
    params(9) = Alpha4
    params(10) = ToImage
    Magick.Convert(params)

我试图用参数提供“convert()”目录:

    Magick.Convert(FromImage, Rotate1, Rotate2, Resize1, Resize2, Extra_Imagemagick_settings, Alpha1, Alpha2, Alpha3, Alpha4, ToImage)

每次我有不同的例外时,通常:

Object reference not set to an instance of an object.

或者

Use the New keyword to create the instance.

(这可能是因为我是 DOT NET 的新手)

4

1 回答 1

2

主要问题是 32/64 位。

我没有设法让它在 100% 64 位下工作(但我也没有太努力)。

  1. 创建一个项目。
  2. 如果您使用的是“vb express”版本,则必须手动编辑 *.vbproj 文件并在每个提到 CPU 的部分之后添加这一行 x86(inernet 中有大量关于它的帖子)。
  3. 此示例取自http://www.imagemagick.org/discourse-server/viewtopic.php?f=8&t=13295 ,它是第一个为我工作的示例(我简化了它)。

    Dim img As ImageMagickObject.MagickImage
    img = New ImageMagickObject.MagickImage
    MSGS = img.Convert("C:\a.bmp", "-resize", "x128", "C:\a.jpg")
    img = Nothing
    
于 2013-03-10T02:01:31.247 回答