overwrite pixel

Just starting out? Need help? Post your questions and find answers here.
5mware
User
User
Posts: 30
Joined: Mon Dec 14, 2015 2:14 pm

overwrite pixel

Post 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
IdeasVacuum
Always Here
Always Here
Posts: 6425
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: overwrite pixel

Post 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))
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
#NULL
Addict
Addict
Posts: 1440
Joined: Thu Aug 30, 2007 11:54 pm
Location: right here

Re: overwrite pixel

Post 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)
User avatar
Kukulkan
Addict
Addict
Posts: 1352
Joined: Mon Jun 06, 2005 2:35 pm
Location: germany
Contact:

Re: overwrite pixel

Post 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.
Post Reply