in

Support Portal

[C#] ERR_PROPERTY_VALUE

Last post 08-14-2007 2:19 PM by mkdev. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 08-14-2007 12:14 PM

    • mkdev
    • Top 25 Contributor
    • Joined on 08-14-2007
    • Patch Code
    • Points 6

    [C#] ERR_PROPERTY_VALUE

    Hi,

    I'm currently trying to implement Volo in a C# application, but running into a problem when trying to set the image to decode. I'm using the below code, pretty much copied from your C# sample:

    System.Drawing.Imaging.BitmapData bmpData = bmp8bpp.LockBits(
                                new Rectangle(0, 0, bmp8bpp.Width, bmp8bpp.Height),
                                System.Drawing.Imaging.ImageLockMode.ReadOnly,
                                System.Drawing.Imaging.PixelFormat.Format8bppIndexed);
    voloret = Volo.Set(volo, Volo.PROP_IMAGE_POINTER, bmpData.Scan0);
    voloret = Volo.Set(volo, Volo.PROP_IMAGE_WIDTH, bmpData.Width);
    voloret = Volo.Set(volo, Volo.PROP_IMAGE_LINE_DELTA, bmpData.Stride);
    voloret = Volo.Set(volo, Volo.PROP_IMAGE_HEIGHT, bmpData.Height);
    voloret = Volo.Set(volo, Volo.PROP_CALLBACK_RESULT, new Volo.Callback(Volo_CBResult));
    

    However, the PROP_IMAGE_LINE_DELTA set returns 0 if bmpData.Stride is negative (which is a perfectly acceptable value). Does Volo not support upside-down bitmaps?

     

    Thanks,

    David
     

    • Post Points: 1
  • 08-14-2007 12:31 PM In reply to

    • mkdev
    • Top 25 Contributor
    • Joined on 08-14-2007
    • Patch Code
    • Points 6

    Re: [C#] ERR_PROPERTY_VALUE

    OK, I discovered the mirrored property and am now trying the following code:

    if (bmpData.Stride < 0)
    {
        voloret = Volo.Set(volo, Volo.PROP_IMAGE_LINE_DELTA, -bmpData.Stride);
        voloret = Volo.Set(volo, Volo.PROP_IMAGE_MIRRORED, Volo.CONST_ENABLED);
    }
    else
        voloret = Volo.Set(volo, Volo.PROP_IMAGE_LINE_DELTA, bmpData.Stride);

    But now I just get an access violation when I call Decode. (I don't change any other Volo properties before I call Decode, it essentially gets called immediately after the above-posted code.)

    • Post Points: 4
  • 08-14-2007 1:21 PM In reply to

    Re: [C#] ERR_PROPERTY_VALUE

    Reading the C# documentation, it looks like the Scan0 property will point to the last line of the data array for an upside down bitmap. SwiftDecoder expects the image pointer to point to the first byte of the data array, with a positive line delta. When you get a negative stride, you need to subtract (Height - 1)*Stride from the Scan0 pointer to point to the base of the image data.

    Regards,

    Bob Dunphy
     

    • Post Points: 4
  • 08-14-2007 2:19 PM In reply to

    • mkdev
    • Top 25 Contributor
    • Joined on 08-14-2007
    • Patch Code
    • Points 6

    Re: [C#] ERR_PROPERTY_VALUE

     Nice catch, worked great. Thanks!

    • Post Points: 1
Page 1 of 1 (4 items)
Copyright Omniplanar, Inc. 2007
Powered by Community Server (Commercial Edition), by Telligent Systems