New topic: Remove the Mask from a Picture
<http://forums.realsoftware.com/viewtopic.php?t=46024> Page 1 of 1 [ 6 posts ] Previous topic | Next topic Author Message tbg10101 Post subject: Remove the Mask from a PicturePosted: Thu Nov 22, 2012 7:44 pm Joined: Mon Feb 05, 2007 6:24 pm Posts: 97 Location: USA Hello all, As we all know, pictures with an alpha transparency are made up of a color picture and a mask. My problem is that I already have a picture with alpha transparency as a PNG file. Getting the mask from the picture is mot a problem because RB will generate it for me by using Picture.Mask(true). I need the picture that, when combined with the mask, results in the final picture with transparency. In other words, I need the color picture without the mask. I have already tried Picture.Mask.Graphics.FillRect(0,0,width,height) with black as my forecolor and all that gets me is the ARGB picture on a white background which is NOT what I want. Any suggestions? Thanks, -Tristan _________________ Sole Proprietor 10101 Software http://www.10101software.co.nr/ RB 2011r4.3, MBS 12.4 Top tbg10101 Post subject: Re: Remove the Mask from a PicturePosted: Thu Nov 22, 2012 8:20 pm Joined: Mon Feb 05, 2007 6:24 pm Posts: 97 Location: USA Update! I implemented a brute force version of what I want: dim p as new picture(c.Picture.Width,c.Picture.Height) p.Graphics.DrawPicture(c.Picture,0,0) dim i,j as integer dim v as color dim s as string while i<p.Width while j<p.height v=p.Graphics.Pixel(i,j) p.Graphics.ForeColor=RGB(v.Red,v.Green,v.Blue) p.Graphics.DrawLine(i,j,i,j) j=j+1 wend j=0 i=i+1 wend ImageWell8.Image=p While this does what I want (changes the alpha of all pixels to 0, opaque) is there a faster way to do this? _________________ Sole Proprietor 10101 Software http://www.10101software.co.nr/ RB 2011r4.3, MBS 12.4 Top DaveS Post subject: Re: Remove the Mask from a PicturePosted: Thu Nov 22, 2012 8:48 pm Joined: Sun Aug 05, 2007 10:46 am Posts: 4292 Location: San Diego, CA try this. p.mask.graphics.forecolor=&cffffff p.mask.graphics.fillrect 0,0,p.mask.graphics.width,p.mask.graphics.height and in regards to your code... for future references.. look at RGBSurface _________________ Dave Sisemore MacPro, OSX Lion 10.7.4 RB2012r1 Note : I am not interested in any solutions that involve custom Plug-ins of any kind Top swort Post subject: Re: Remove the Mask from a PicturePosted: Thu Nov 22, 2012 8:52 pm Joined: Mon May 31, 2010 5:35 am Posts: 2259 Location: Netherlands i'm not sure if this works, but if i read the docs right then it should help: Here is some code from the documentation: Function ModernizePicture(input As Picture) As Picture If input.HasAlphaChannel Then Return input 'Picture already has an alpha channel Dim result As New Picture( input.Width, input.Height ) 'Create a resulting picture result.Graphics.DrawPicture( input, 0, 0 ) Return result 'This one should now have an alpha channel too End Function found here with explanation: http://docs.realsoftware.com/index.php/Picture.HasAlphaChannel _________________ SWORT⢠- Windows Vista, Windows XP, Windows 7, Linux Mint 11 and Mac OSX Lion - REAL Studio Enterprise(latest) and WEB Edition(latest) - Plugins (MBS Complete, ToringoLib, Einhugur, VanHoek + Some open source plugins) For Dutch User Groups ask me to enter! Top tbg10101 Post subject: Re: Remove the Mask from a PicturePosted: Thu Nov 22, 2012 9:06 pm Joined: Mon Feb 05, 2007 6:24 pm Posts: 97 Location: USA Here is my issue in visual form: I currently have this picture which already has alpha transparency... (call this 'a') ..and I can easily get the mask because RB generates it for me... (call this 'm') .but I want to extract this image: (call this 'p') So, let's say a=p+m. I want to do the function p=a-m to get the third picture above. @swort Could you explain how that applies? Should I modernize the image then fill the mask with black? @DaveS Won't that just make the image completely transparent because the mask is entirely white? _________________ Sole Proprietor 10101 Software http://www.10101software.co.nr/ RB 2011r4.3, MBS 12.4 Top tbg10101 Post subject: Re: Remove the Mask from a PicturePosted: Thu Nov 22, 2012 9:21 pm Joined: Mon Feb 05, 2007 6:24 pm Posts: 97 Location: USA @DavidS Thanks for the RBGSurface suggestion, I implemented it instead of DrawLine in Graphics and it is blindingly fast! _________________ Sole Proprietor 10101 Software http://www.10101software.co.nr/ RB 2011r4.3, MBS 12.4 Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 6 posts ]
-- Over 1500 classes with 29000 functions in one REALbasic plug-in collection. The Monkeybread Software Realbasic Plugin v9.3. http://www.monkeybreadsoftware.de/realbasic/plugins.shtml [email protected]
