Page 1 of 1

overwrite pixel

Posted: Thu Dec 07, 2017 12:15 pm
by 5mware
hi guys,

i have a question. imagine you load a jpeg image. the goal is to transform that jpeg into a partial transparency image. that means, that you move the mouse pointer over the image an regions under the mouse pointer becomes transparent.

i have a slowly quick&dirty solution with dim-redim, copy pixel, compair with position etc. that works fine. but as mentioned very slowly.

is there a way, without using arrays and image-copies, to do it like that:

Code: Select all

If img
  If StartDrawing(ImageOutput(img))
    DrawingMode(#PB_2DDrawing_AlphaBlend)
    tempcolor = Point(mousex,mousey)
    maketransparent(tempcolor)
    Plot(mousex,mousey,tempcolor)
    StopDrawing()
  EndIf
EndIf
kind regards

kurt

Re: overwrite pixel

Posted: Thu Dec 07, 2017 10:53 pm
by IdeasVacuum
The image needs to be 32bit for Point to return the current Alpha value (RGBA), but if you simply want to apply a fixed level of transparency at every pixel picked, then you don't need your Procedure maketransparent, you can simply specify the Alpha value in Plot(x, y, RGBA). An Alpha value of zero means fully transparent and a value of 255 means fully opaque.

Code: Select all

PixColour = Point(x, y)
Plot(x, y, RGBA(Red(PixColour), Green(PixColour), Blue(PixColour), Alpha(50))

Re: overwrite pixel

Posted: Fri Dec 08, 2017 2:58 pm
by #NULL
IdeasVacuum wrote:

Code: Select all

PixColour = Point(x, y)
Plot(x, y, RGBA(Red(PixColour), Green(PixColour), Blue(PixColour), Alpha(50))
you need to specify the alpha value without using Alpha(), otherwise 50 is interpreted as a complete color, a dark red with alpha 0.

Code: Select all

Debug Alpha(50)
Debug 50
Debug Alpha($32000000)

Re: overwrite pixel

Posted: Sat Dec 09, 2017 10:15 am
by Kukulkan
Not sure, but isn't the DrawingMode #PB_2DDrawing_AlphaChannel exactly for this? By this, you also may not need to first get the pixel color. From the documentation, it just draws onto the alpha channel.