It is currently Tue Jul 17, 2018 10:31 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: overwrite pixel
PostPosted: Thu Dec 07, 2017 12:15 pm 
Offline
User
User

Joined: Mon Dec 14, 2015 2:14 pm
Posts: 15
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:
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


Top
 Profile  
Reply with quote  
 Post subject: Re: overwrite pixel
PostPosted: Thu Dec 07, 2017 10:53 pm 
Offline
Always Here
Always Here

Joined: Fri Oct 23, 2009 2:33 am
Posts: 5774
Location: Wales, UK
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:
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.


Top
 Profile  
Reply with quote  
 Post subject: Re: overwrite pixel
PostPosted: Fri Dec 08, 2017 2:58 pm 
Offline
Enthusiast
Enthusiast

Joined: Thu Aug 30, 2007 11:54 pm
Posts: 726
Location: right here
IdeasVacuum wrote:
Code:
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:
Debug Alpha(50)
Debug 50
Debug Alpha($32000000)


Top
 Profile  
Reply with quote  
 Post subject: Re: overwrite pixel
PostPosted: Sat Dec 09, 2017 10:15 am 
Offline
Addict
Addict
User avatar

Joined: Mon Jun 06, 2005 2:35 pm
Posts: 1147
Location: germany
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.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: Desynchronised, shamun and 33 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye