Brush Mask

I want a Brush Mask such that the color is maximum at the center and the color fades out as the distance from the center increases. This fading is also
dependend on the opacity and the hardness of the brush like that in PaintShop Pro. I would be grateful if u could help me out with this.
AnishaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

akalmaniCommented:
Quiet intersting !!
0
AnishaAuthor Commented:
hi,
Where is the solution to the problem???????
0
nietodCommented:
Standard C++ provides no facilities for graphics.  This sort of thing has to be done through Operating System specifc techniques.  So we would have to know what operating system.

FYI neither windows not Macintosh (At leat Mac of 10 years ago) provides features for doign this directly.  On these OSs you woudl have to do the drawing work "maunually" by specifying the colors of each pixel effected.
0
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

AnishaAuthor Commented:
Hi;
Sorry for not being specific in my question. I shall try and explain, i am working on Image processing in VC++ 6.0 and i am trying to create brush which has the same effect as that in PaintShop Pro , but somehow the effect is not working out. The opacity and hardness is not getting applied properly, also the speed of the brush is slow.Can somebody help me in this.

Thank u
Anisha.
0
nietodCommented:
How are you doing this?  The windows API does not have brushes that have "opacity and hardness" so you have to be doing all this manually, right?
0
akalmaniCommented:
HI Anisha !!
  Just an extension to what nietod has said, u have to do it manually there is no API or any MFC class function to do it. U have to do it pixel by pixel for any particular area where u want to draw. The opacity and hardness can be given as u said. I was not sure about his so i searched in msdn. May be this information will help u.
0
nietodCommented:
Thanks, that is clearer, except you say "opacity and hardness can be given"  Do you mean the windows API does support these?  
0
AnishaAuthor Commented:
Hi Akalmani and Nietod,
   Yes , Akalmani is right , i am processing it pixel by pixel, and applying formulas to obtain opacity and hardness , no windows API does not support  this i have used some image processing formulas.

Anisha

0
nietodCommented:
It sounds like you are already doing this though, are you?  What exactly do you need help with?  The algorithm for setting the pixels? The  interface for allowing the user to draw?  I'm not sure what you have and I'm not sure what you are looking for.
0
AnishaAuthor Commented:
Hi nietod;
   Sorry about not being clear to u . I am new to this site and probably i have selected the wrong category, but still i shall repeat myself.
Look, i am developing an application in VC++ 6.0 related to image processing. Yes i have almost done it . If u can refer to PaintShop Pro and see the brush effect given there , it is solid in the middle but keeps fading outwards depending on hardness and opacity.
i want the algo for such a brush effect.
0
nietodCommented:
Basically what you need to do is a weighted average of the brush's color and the color of the pixel under the brush.  You will need to do this average for each of the color compontents (Reg, Green, BLue) seperately.  For a single color component you would do

NewColor = ( (1 - Opacity)*OldColor + Hardness*BrushColor) / (Hardness+1-Opacity);

This assumes Opacity goes from 0 meaning clear to 1 meaning opach.  Hardness is an open ended scale starting from 0.  (Although you don't have to support very high values. 256 would be VERY hard.  1, would probably be about medium.



0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.