|
|
Thanx, I had a look at the code, and at some more documentation..and tried that on a small test project, to load a bitmap on a pictureBox, and modify its alpha channel as much as a trackBar in the same form is scrolled, from 0 to 1.
The problem is that: once I have create the Graphics object, loaded with my image, and modified it, I can't reconvert it as a Bitmap object, in such a way to be able to set it as the Image property of the PictureBox of the Form.
Notice this is just a small piece of code to try the matter: actually, in my application, I have to load the bipmap as the BackgroundImage property of a Button, but I don't think this changes a lot..
Thanx for any extra help, sorry for my English..
Here down is listed the code I can't fix:
public partial class Form1 : Form
{
private string sourceFileName;
private string destFileName, proposedDestFile;
private Bitmap image, newImage;
private int modifiedImagesCounter;
ColorMatrix colorMatrix;
ImageAttributes imageAtt;
Graphics g;
public Form1()
{
InitializeComponent();
float[][] matrixItems = {
new float[] {1, 0, 0, 0, 0},
new float[] {0, 1, 0, 0, 0},
new float[] {0, 0, 1, 0, 0},
new float[] {0, 0, 0, 1, 0},
new float[] {0, 0, 0, 0, 1}};
colorMatrix = new ColorMatrix(matrixItems);
imageAtt = new ImageAttributes();
imageAtt.SetColorMatrix(colorMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
}
private void loadImageButton_Click(object sender, EventArgs e)
{
openFileDialog.ShowDialog(Parent);
sourceFileName = openFileDialog.FileName;
image = new Bitmap(sourceFileName);
Console.WriteLine("The file to modify is: " + sourceFileName);
//IndexedToARGB_Converter conv = new IndexedToARGB_Converter(sourceFile);
//Bitmap modifiedImage = conv.getNewImage();
pictureBox.Image = image;
}
private void saveImageButton_Click(object sender, EventArgs e)
{
proposedDestFile = DestFileName();
saveFileDialog.FileName = proposedDestFile;
saveFileDialog.ShowDialog(Parent);
destFileName = saveFileDialog.FileName;
Console.WriteLine("The modified file will be saved to: " + destFileName);
newImage.Save(destFileName);
}
private string DestFileName()
{
modifiedImagesCounter++;
StringBuilder strbld = new StringBuilder();
strbld.Append(sourceFileName, 0, sourceFileName.Length - 4);
strbld.Append(modifiedImagesCounter.ToString());
strbld.Append(".GIF");
return strbld.ToString();
}
private void trackBar_Scroll(object sender, EventArgs e)
{
g = pictureBox.CreateGraphics();
//Graphics g = Graphics.FromImage(image);
TrackBar trackBar = (TrackBar)sender;
float f = (float)(trackBar.Maximum - trackBar.Value) / (float)(trackBar.Maximum - trackBar.Minimum);
colorMatrix[3, 3] = f;
int iWidth = image.Width;
int iHeight = image.Height;
Rectangle rect = new Rectangle(pictureBox.Location.X, pictureBox.Location.Y, iWidth, iHeight);
g.DrawImage(
image,
rect, // destination rectangle
0.0f, // source rectangle x
0.0f, // source rectangle y
iWidth, // source rectangle width
iHeight, // source rectangle height
GraphicsUnit.Pixel,
imageAtt);
this.Update();
}
}
|
|
|
|
|
Does anyone have experience calling a Cobol/DB2 stored procedure from .NET? It is not an easy thing to find on the web as I'm sure most companies have tried to get away from this. We still have them because they must serve as the link between our distributed apps and an IMS Database
|
|
|
|
|
Hello
i am using c#.
i am sending one link in email.
when i got email and i click on the link i want to run the code from that perticular page which is linked to the link, but without opening the link.
means ethe code should be run from background.
is this possible?
please help me its urgent.
|
|
|
|
|
Why would you want to do this?
No user will want to have code run from some strange site (not even visible and without agreement) just by clicking a unsuspicious looking link in a eMail.
Nor is this a good think to do - what's if the user is using MacOS or some other OS (or didn't install the .net runtime etc.)?
If you want to know how you can write viruses, worms and co. you will have to look elsewhere (and you won't use C# ) ....
|
|
|
|
|
|
Have it actually link to a page that does the work. Look into ASP.NET.
If you are writing a virus, don't cite me... : )
The best way to accelerate a Macintosh is at 9.8m/sec² - Marcus Dolengo
|
|
|
|
|
Rupali Kombade wrote: i am using c#.
i am sending one link in email.
when i got email and i click on the link i want to run the code from that perticular page which is linked to the link, but without opening the link.
means ethe code should be run from background.
is this possible?
No one is going to help you write a virus. If it isn't a virus, it's a terrible, awful idea. Still, no one will help you.
Rupali Kombade wrote: please help me its urgent.
Oh, it's urgent, huh? Oh that is completely different then? Would you also like us to make you dinner and rub your feet while we are doing your work?
I'm going to become rich when I create a device that allows me to punch people in the face over the internet.
"If an Indian asked a programming question in the forest, would it still be urgent?" - John Simmons / outlaw programmer
|
|
|
|
|
Hi Guy
exactlly this is possbile. Ho do you mean?
create a process class object when you wiull be clikc the link and pass fille is "Iexpolrer.exe", and pass args your link.
after call start method in that process object.
Thanks
Cheers
RRave
MCTS,MCPD
|
|
|
|
|
|
Problem solved!!!
Turns out that im right about the Time Offset, i just needed to shift the boolean array acording to my time zone....
|
|
|
|
|
Hi friends,
I want to search a word/phrase of words(Like search inGoogle) in XLs/PDf or Doc file.The files are Stored under a folder in local machine.The application as a ASP.Net Application using C#.
But i am finding no way out there to do so.i need ur help.
Please help me in this regard.
|
|
|
|
|
|
Hi guys
im sitting with a little delema. i need to determine which kind
of SqlException was thrown by sql. i tried using SqlException.ErrorCode like so
<code lang="cs">
try
{
}
catch(SqlException sqlEx)
{
if(sqlEx.ErrorCode == -2146232060)
{
}
else
{
means of a messageBox that displays the
errorCode and errorMessage
}
}
</code>
now i initially thaught that -2146232060 is the error code for violating a unique constraint, but i later noticed that the exact same code is used when there is no longer access to the db
i need to be able to handle these exceptions in different ways
how exactly can i determine what actualy went wrnog on the sql end so that i can prompt the user accordingly EG. "user alredy exists" or "database no longer avalible"
thanx
Harvey Saayman - South Africa
Junior Developer
.Net, C#, SQL
think BIG and kick ASS
|
|
|
|
|
Hello,
As the SqlException can return more than one, you would have to iterate over the Errors (SqlError[]) and check the "Number" Property there.
MSDN Example:
catch(SqlException exception)
{
for (int i = 0; i < exception.Errors.Count; i++)
{
Console.WriteLine("Index #" + i + "\n" +
"Source: " + exception.Errors[i].Source + "\n" +
"Number: " + exception.Errors[i].Number.ToString() + "\n" +
"State: " + exception.Errors[i].State.ToString() + "\n" +
"Class: " + exception.Errors[i].Class.ToString() + "\n" +
"Server: " + exception.Errors[i].Server + "\n" +
"Message: " + exception.Errors[i].Message + "\n" +
"Procedure: " + exception.Errors[i].Procedure + "\n" +
"LineNumber: " + exception.Errors[i].LineNumber.ToString());
}
Console.ReadLine();
}
All the best,
Martin
|
|
|
|
|
Thanx! it worx perfect
Harvey Saayman - South Africa
Junior Developer
.Net, C#, SQL
think BIG and kick ASS
|
|
|
|
|
Glad I could help!
You are wellcome!
All the best,
Martin
|
|
|
|
|
Wouldn't this befit SQL/aDO.NET forums rather?
Vasudevan Deepak Kumar
Personal Homepage Tech Gossips
A pessimist sees only the dark side of the clouds, and mopes; a philosopher sees both sides, and shrugs; an optimist doesn't see the clouds at all - he's walking on them. --Leonard Louis Levinson
|
|
|
|
|
People get confused as to where to post questions all the time. I can see where the confusion would come from if you are coding in C# and having SQL issues. There are two forums to post the question. Usually they just post the question in both spots, and about just as often, they post on completely wrong forums.
The best way to accelerate a Macintosh is at 9.8m/sec² - Marcus Dolengo
|
|
|
|
|
Hi everybody!
I want to develop a dll using C# which can capture client screen. After build dll I will use into my asp page as following example :
<%
set ob = Server.CreateObject("namespace.PublicClass")
.....
ob.CaptureScren()
.....
%>
Can anybody help me?
Thanks to all..
monsur hoq
|
|
|
|
|
making a screeshot of the client machine from within an asp page?
i don´t think that this is possible at all...
|
|
|
|
|
|
well , i don't think there is a way of making client-side screenshots from within an asp page (as long as you stay with asp and don't talk about activex controls and such stuff).
actually it's a good thing that an asp page just cannot make client-side screenshots.
otherwise you would run into some serious security problems.
the only thing you could probably make is a rendered image of your website, but that would just contain the website and nothing else.
why do you want to make screenshots from within asp?
joachim
|
|
|
|
|
I want to make such a web application for creating presentation as user demand. Pls help me.
|
|
|
|
|
i just cannot see what presentations and screen shots have in common...
|
|
|
|
|