TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Tyler Miles
NA
11
1.1k
I can't pass parameter to method.
Aug 3 2019 9:29 AM
Hi, i am new with C# and OOP.
I created a method (it blurs an image) . And it works well. I will create another method. And i need blurred image as input parameter. But i don't know how to do this? (I tried something. But none of them didn't work)
Here is my try:
private
void
sliderKernel_MouseUp(
object
sender, MouseEventArgs e)
{
Filtreler f1 =
new
Filtreler();
//Filtreler is name of my class
f1.Img =
new
Bitmap(pBox_SOURCE.Image);
int
kernelsize = sliderKernel.Value;
Bitmap MeanImg = f1.meanfilter(kernelsize, f1.Img);
//this method works well.now, i would like to use MeanImg
pBox_PROCESSED.Image = MeanImg;
f1.CorrectShade(f1.Img, MeanImg);
//But i can't. All the pixel values are come as zero
pBoxShadeCorrection.Image = MeanImg;
}
public
Bitmap Img {
get
;
set
; }
//my Properties
public
Color PixelValue {
get
;
set
; }
public
Bitmap meanfilter(
int
kernelsize, Bitmap InputImage)
{
Bitmap CikisResmi =
new
Bitmap(GirisResmi.Width, GirisResmi.Height);
//blurring operations
return
CikisResmi;
//I blurred the image. No problem with this method
}
public
Bitmap CorrectShade(Bitmap InputImage,Bitmap BlurredImage)
{
Color PixelVauleBlurred;
int
divR,x,y;
int
ImgWidth = InputImage.Width;
int
ImgHeight = InputImage.Height;
for
(x = 0; x < ImgWidth; x++)
{
for
(y = 0; y < ImgHeight; y++)
{
PixelVauleBlurred = BlurredImage.GetPixel(x, y);
PixelValue = InputImage.GetPixel(x, y);
divR = Convert.ToInt16(1f*OkunanRenk.R / PixelVauleBlurred.R);
//Error line
//
Error message:System.DivideByZeroException: 'Attempted to divide by zero.'
BlurredImage.SetPixel(x, y, Color.FromArgb(divR, divR, divR));
}
}
return
BlurredImage;
}
Reply
Answers (
7
)
How to add an event to a static method in a class?
Make input and output