[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 308
  • Last Modified:

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.
0
Anisha
Asked:
Anisha
  • 5
  • 4
  • 2
1 Solution
 
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
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
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

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

  • 5
  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now