Results 1 to 11 of 11

Thread: is5_DropShadow error detection

  1. #1
    Join Date
    Jun 2005
    Location
    Fargo, ND, USA.
    Posts
    126

    Default is5_DropShadow error detection

    I am having a problem with is5_DropShadow intermittently failing.

    I am pretty sure it's my fault for providing too small a buffer for the dropshadow. I am working on figuring out why my buffer is too small.

    However, if is5_DropShadow doesn't have enough room to do it's job, shouldn't it return an error instead of just crashing?

    Thanks,

    Paul Samuelson

  2. #2
    Join Date
    Mar 2006
    Posts
    942

    Default Re: is5_DropShadow error detection

    There's no way for ImgSource to know the size of the buffer you've passed in. Windows provides no mechanism to know how much memory was allocated, given an arbitrary pointer.

    How are you determining the output buffer size?

  3. #3
    Join Date
    Jun 2005
    Location
    Fargo, ND, USA.
    Posts
    126

    Default Re: is5_DropShadow error detection

    The drop shadow is for a text layer. I use is5_GetTextLineSize2 to find the size of the text, then do some calculations (that are apparently flawed) to calculate a margin for the shadow or outerglow. I add the buffer to the height and width, multiply and multiply by 4, then create the buffer.

    is5_DropShadow does know the size of the buffer, or at least what is allocated to it, because it is passed as parameters. It can't write outside the passed dimensions, but I think it is failing if it wants to write outside them.

  4. #4
    Join Date
    Mar 2006
    Posts
    942

    Default Re: is5_DropShadow error detection

    Actually, I spoke too soon.

    is5_DropShadow doesn't need you to allocate anything. It handles the allocation of the image, and passes the allocated buffer and the dimensions back to the caller. So, how are you calling it?

  5. #5
    Join Date
    Jun 2005
    Location
    Fargo, ND, USA.
    Posts
    126

    Default Re: is5_DropShadow error detection

    I though I was passing dimensions, but you are right, they are being passed back to me.

    tLayerW and tLayerH are the dimensions of tLayer which holds the text image
    dsLayer, bW and bH are 4 Byte buffers
    lfheight is the text height in pixels
    dsOffset is a small ratio (0.05)
    dsDiffusion is 0.5
    colors vary
    dsAngle is 135
    bOverlayOffset and bShadowOffset are 8 Byte buffers

    DllCall(IS5,long:"_is5_DropShadow",lpbinary:tLayer ,long:tLayerW,long:tLayerH,long:4,long:tLayerW*4,l pbinary:dsLayer,lpbinary:bW,lpbinary:bH,long:Int(l fHeight*dsOffset),long:Int(dsDiffusion*lfHeight),l ong:dsbColorDec,long:dsColorDec,long:dsAngle,lpbin ary:boverlayOffset,lpbinary:bshadowoffset,long:2)

  6. #6
    Join Date
    Jun 2005
    Location
    Fargo, ND, USA.
    Posts
    126

    Default Re: is5_DropShadow error detection

    I finally figured out my problem. I was multiplying the text height by the diffusion factor (apparently like I do for OuterGlow). In cases where the text was large enough, the product exceeded the allowed range of 1 to 100.

    Back to my original question (with more information now) - Should is5_DropShadow report an error instead of crashing when a parameter is exceeded? Maybe.

    Thanks,

    Paul

  7. #7
    Join Date
    Mar 2006
    Posts
    942

    Default Re: is5_DropShadow error detection

    "Should is5_DropShadow report an error instead of crashing when a parameter is exceeded?"

    Which parameter are you exceeding? All the values you reported above look reasonable.

  8. #8
    Join Date
    Jun 2005
    Location
    Fargo, ND, USA.
    Posts
    126

    Default Re: is5_DropShadow error detection

    The diffusion sometimes went over 100, depending on the text height.

  9. #9
    Join Date
    Mar 2006
    Posts
    942

    Default Re: is5_DropShadow error detection

    well, there is no real upper limit on the diffusion parameter. it has a direct relationship to the size of the output, though. and 100 x the image height for diffusion is going to get you a very large output image. there's a good chance there's an out-of-memory issue somewhere in there (because there are a lot of temporary images used in this process, which have to be as large as the output), but i haven't been able to duplicate it.

    how much memory is on your PC, and how large is your input image when the problem happens?

  10. #10
    Join Date
    Jun 2005
    Location
    Fargo, ND, USA.
    Posts
    126

    Default Re: is5_DropShadow error detection

    The text layer handed off to is5_DropShadow is only few hundred by maybe a couple thousand pixels. The machine has 4GB of RAM. I don't think it was running out of memory.

    My code changes stopped the crashing, but 5.0.6.6 did not.

    I'm still confused by this. I changed the diffusion formula so it ends up between 1 and 100, and I simplified my buffer margin calculations and now it works fine. I tested diffusion up to 4000, which gives really strange results, but does not crash. My margin calculations should only change the size of the image given to is5_DropShadow, and the distance from the text is to the edge of the buffer. Is it possible the problem is image content related, especially at the edge of the image?

    An unrelated question regarding is5_DropShadow: What is the background diffusion color supposed to do? It doesn't seem to do anything for me.

  11. #11
    Join Date
    Mar 2006
    Posts
    942

    Default Re: is5_DropShadow error detection

    Quote Originally Posted by paul s View Post
    Is it possible the problem is image content related, especially at the edge of the image?
    i don't see anything in the shadow stuff that cares about the position of image data.

    can you narrow the problem down to a specific input image, and set of parameters? i haven't been able to get any kind of crash.

    Quote Originally Posted by paul s View Post
    An unrelated question regarding is5_DropShadow: What is the background diffusion color supposed to do? It doesn't seem to do anything for me.
    clrBackground is the color of the background for non-RGBA images, or when uFlags is 0. the function creates the output image, fills it with this color, then draws the shadow on top of that, then overlays the input image.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •