C# Pattern Overlay and load image

  • Thread starter Thread starter ggyy426
  • Start date Start date
G

ggyy426

Guest
I try to write a Window Form app for desktop with C#.

Window Form app function is load image and do image overlay like photoshop.

But I don't know how to load image outside function like:



I know C# has OpenFileDialog class can create function like photo below.

But I still need to create a struct to load image need image name or image ID for my function to call image to use.

Like C# property.resource.image(call my image name)

And I also face one more issues like How to achieve Image Ovelay

In C# I can just use panel and pictureBox to achieve put pictureBox on panel.

And Set panel backColor Transparent.

But In my Window Form something wrong.

Here is my code:

private void AddNewPhotoToolStripButton_Click(object sender, EventArgs e)
{
/*
var fileContent = string.Empty;
var filePath = string.Empty;

using (OpenFileDialog openFileDialog = new OpenFileDialog())
{
openFileDialog.InitialDirectory = "c:\\";
openFileDialog.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
openFileDialog.FilterIndex = 2;
openFileDialog.RestoreDirectory = true;
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
//Get the path of specified file
filePath = openFileDialog.FileName;

//Read the contents of the file into a stream
var fileStream = openFileDialog.OpenFile();

using (StreamReader reader = new StreamReader(fileStream))
{
fileContent = reader.ReadToEnd();
}
}//end if
}
MessageBox.Show(fileContent, "File Content at path: " + filePath, MessageBoxButtons.OK);
*/
Panel backGround = new Panel();
backGround.Location = new System.Drawing.Point(67, 57);
backGround.Size = new System.Drawing.Size(800, 480);
backGround.BackgroundImage = Properties.Resources.fullground;
backGround.BackColor = Color.Transparent;
Controls.Add(backGround);
backGround.BringToFront();
}

private void OvelayPhotolStripButton_Click(object sender, EventArgs e)
{
PictureBox a =new PictureBox();
a.Location = new System.Drawing.Point(200, 107);
a.Size = new System.Drawing.Size(200, 50);
a.BackgroundImage = Properties.Resources.needle;
a.BackColor = Color.Transparent;
Controls.Add(a);
a.BringToFront();
}
}


So far I am not doing openFileDialog so I comment it and use resource to load image.

I can't achieve photo overlay by set panel backColor to transparent

the result is ike Photo belo

All my fullGround and needle images are .png file but it can't achieve photo overlay.

How can I solve these two problems?

1.Create a function to load image like first image show and load in my struct to use?

2.Solve Photo overlay?

Thanks


Sorry so far i can't add image

Continue reading...
 
Back
Top