Results 1 to 5 of 5

Thread: [RESOLVED] Pré-multiplying images

  1. #1

    Thread Starter
    New Member Pix_Man's Avatar
    Join Date
    Nov 2019
    Posts
    11

    Resolved [RESOLVED] Pré-multiplying images

    Hello friends,
    After pre-multiplying the image of the globe with the mask, and drawing it on the canvas, there is a dark shadow around the image, how can I remove the dark shadow and leave only the blue light of the golobo ?, And how to save this image in transparent png?, Thank you.
    Note: Code attached.

    Name:  img1.jpg
Views: 214
Size:  51.7 KB

    Pré-multiplying images.zip
    Last edited by Pix_Man; Nov 27th, 2020 at 03:51 PM.

  2. #2
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,219

    Re: Pré-multiplying images

    Your mask already contains "the gaussian-blurred masking-area".

    So there's no reason, why your original image should contain an "already Cyan-ish masked against Black" conture...

    Just let the mask(-image) do its job - and try it with this simpler image in your Source (picImg.Picture):



    The above should be "copyable" (downloadable as a JPG) in the same size as your images (200x200).

    HTH

    Olaf

  3. #3
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,120

    Re: Pré-multiplying images

    Your image is already pre-multiplied.

    This works
    Code:
        For x = 0 To bmi.bmiheader.biWidth * bmi.bmiheader.biHeight * 4 - 1 Step 4
    '        pix = BBYTES(x + 0): pix = pix * ABYTES(x) / 255: BBYTES(x + 0) = pix
    '        pix = BBYTES(x + 1): pix = pix * ABYTES(x) / 255: BBYTES(x + 1) = pix
    '        pix = BBYTES(x + 2): pix = pix * ABYTES(x) / 255: BBYTES(x + 2) = pix
            BBYTES(x + 3) = ABYTES(x)
        Next
    (Skip pre-multiplying, only copy alpha)

    cheers,
    </wqw>

  4. #4
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,219

    Re: Pré-multiplying images

    Quote Originally Posted by wqweto View Post
    Your image is already pre-multiplied.
    Yep - and the step which produced that "original, premultiplied image" -
    was apparently already using "existing alpha-information" in that pre-multiplying-stage...
    And at this occasion could already have stored the used AlphaMask-bytes in the first place:
    - within the "4th-Byte" of a 32bpp-DIB target
    - and afterwards saving the whole thing as either a 32bpp *.bmp (or alternatively as a *.png).

    Afterwards no Extra-Masking steps (via special Mask-bitmaps) would be needed anymore ...
    The 32bpp *.bmp would be directly loadable - and "AlphaBlend-Blittable".

    So the OP is good advised, to reconsider his whole "workflow"...
    - from the "design-phase" - and what output it should produce
    - to the "usage-phase" within a given CodeBase

    Blending-Ops which require the managing of two separate Resources (Input-Files) to become usable,
    are (IMO) a thing of the past.

    Olaf

  5. #5

    Thread Starter
    New Member Pix_Man's Avatar
    Join Date
    Nov 2019
    Posts
    11

    Re: Pré-multiplying images

    Thank you very much Olaf and wqweto

    Name:  img2.jpg
Views: 152
Size:  52.1 KB
    Last edited by Pix_Man; Nov 30th, 2020 at 05:53 PM.

Posting Permissions

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



Click Here to Expand Forum to Full Width