|
|
half-life wrote: and the thing is that Pressing the Enter button or not does;nt change the fact that the value has changed
It has changed on the screen, but has it changed in the bindinglist?
But why should anyone answer your question? You obviously know all the answers already!
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
|
Oh really, it's no problem!
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Okay, I thought this should be for a new thread....
I have an existing image.
originalImage = new Bitmap(path.ToString());
Bitmap newImage = new Bitmap(originalImage.Width, originalImage.Height);
g = Graphics.FromImage(newImage);
Matrix matrix = new Matrix();
matrix.Rotate(10f);
g.TranslateTransform( ((float)originalImage.Width) / 2, ((float)originalImage.Height) / 2);
g.RotateTransform(10f);
g.TranslateTransform(-((float)originalImage.Width) / 2, -((float)originalImage.Height) / 2);
g.DrawImage(originalImage, 0, 0);
This works just as I want it to in terms of rotating on an axis in the center of a picture instead of 0,0 (x,y)coords. However, say my original picture is (wXh) 473x640 and when resized 10f I know it's supposed to be 577x712 or so. The reason it's bigger is that when the picture is rotated, say, angle of 10, the top left corner is no longer within the original dimension of the image and therefore apear cut off. I do not want this. I want the image to resize as needed to fit the entire contents of a rotated image.
Any idears? Setting the g.DrawImage and setting the width height, even to the known values needed, just exands the image is the Graphics object, so it appears, already lopped off parts of my image to stay within the initial constraints. I don't know how to mkae the Graphic larger bigger without affecting the Bitmap it initially used....
If there are any good sources for .net graphics that'd be great. I can't find an examples in dr. google and my pro c# book doens't have any such examples.
|
|
|
|
|
You're on the right step with your translate code, so that you rotate around the centre. I'm not sure how to calculate the required size of the new image, but obviously you need to know it when you create newImage, so you can create an image of the right size. I would imagine you could work out some triangles that are formed by the outline of the old image and the new one, and use trig to work out the length of the new sides, and thus work out the size of your new image.
Christian Graus
Driven to the arms of OSX by Vista.
"I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
|
|
|
|
|
Hello,
Well, instead of doing the hard work I used another program to rotate 10 degrees and it resized appropritately (at least visually). From this I gathered the new dimensions of what the resized picture should be.
Still, armed with this it does now good to set the size of the new image using g.drawImage() because the image within graphics object is already chopped up. So all setting the new image with the larger widthXheight known values does is create a bigger 'chopped up' pic. ;-]
It's strange, I thought perhaps setting the variable newImage = bitmap() with the known values, but that just make the initial picture bigger and therefore the result (g.drawimage()) equally bigger (compared to original image dimension), but still it's chopped up.
What the problem is, i think, is that the Graphics object somehow needs to be enlarrged before I call the rotate function... well, that's sort of what I've narrowed it down to. It's funny, moments ago I even found a really good exmpale of roating a Graphics...but, still, they didn't account for the resizing issue.
|
|
|
|
|
FrankeyJames wrote: is that the Graphics object somehow needs to be enlarrged before I call the rotate function...
Yeah, if you rotate the original image, which is too small, then it's obviously going to get chopped ont he side. As I said, you can't resize a grpahics object.
Christian Graus
Driven to the arms of OSX by Vista.
"I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
|
|
|
|
|
Yeah...
I think I got it now. I think I figured out what is wrong. Now I just need to do this math calculation so it's automated....
If and when I get a godo solutiong working I'll post it here.
|
|
|
|
|
Hi again,
As you figured out, it is easiest to translate things such that the origin is at the center.
These are the equations that rotate a point (x1,y1) around the origin over an angle alpha, whose cosine and sine are cosa and sina:
x2 = x1 * cosa + y1 * sina
y2 = -x1 * sina + y1 * cosa
If you apply that to the rightmost top and bottom points (W1/2,H1/2) and (W1/2, -H1/2) where W1 and H1 are original width and height, you get two new points one of which will have the extreme X value (hence half of the new width) the other the extreme Y value (half of the new height).
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
Hi,
I have a system web page (c#) that is running within the company there is one process in the system that needs approval from vendor/supplier within the company (separate office). The request is that thay just want to receive email notification for approval using MS outlook and then there are 2 buttons (approved/reject) either of the two should execute the SQL statement that will update the flag of the record table.
Any suggestions on how to do it?
My solution:
I created a web page where all the updates for approve/reject was there. I can send outlook message to the users with 2 buttons. Once he click either of the two it will run the web page and should execute the SQL statement. Unfortunately, nothing happen. At the same time the web page should close automatically.
Regards
Dabsukol
|
|
|
|
|
Your client is making stuff up. Real developers step in and tell people why they can't have anything they like.
In this world, Outlook limits what it will display/allow because of all the viruses out there. I would not be surprised if what they want, won't work.
Christian Graus
Driven to the arms of OSX by Vista.
"I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
|
|
|
|
|
Hi
how can i build FTP client for copy files from the server to other computers
and terminal ?
thank's in advance
|
|
|
|
|
This is not the place for asking anything related to basic networking or whatever. We only solve programming problems, that too only if the code is provided for rectification. Got it?
|
|
|
|
|
|
Hi
I am copying file using SafeFileHandle but if source folder contains any hidden file it also get copy but in destination it is not a hidden file. I want that after copy the attributes remain the same.
Please Help
Thanks in Advance.
|
|
|
|
|
Just read all file attributes before copying, then set the attributes after copying.
|
|
|
|
|
Hi there,
I am creating a removable tool for a particular worm, which copies itself to C:/System32 directory as the root. Then it tries to spread via the SMTP or whatever like that protocol. However, when I delete the root copy of the worm from the C:/System32 directory, it agains get created in that location. Therefore, I have written a C# console application to kill this worm. I have written the following one line code to delete this worm whenever it copies itself to C:/System32 folder as deletion:
//This is in spontaneous loop
System.IO.File.Delete(@"C:/System32/Loveu(worm).exe");
However, since loop is implemented here, the black screen becomes very visible and just remains in a visible mode. Therefore, my question is, how will I hide a console application process during its runtime(incase the process is too long)?
Your help will be really appreciaed,
Rajdeep.NET
|
|
|
|
|
Haven't tried this.....
Jus got some time back while googling....
Try it out and post a reply if it works...
using System.Runtime.InteropServices;
[DllImport("user32.dll")]
public static extern IntPtr FindWindow(string lpClassName,string lpWindowName);
[DllImport("user32.dll")]
static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
caption depending on the system you are running under.
IntPtr hWnd = FindWindow(null, "Your console windows caption");
if(hWnd != IntPtr.Zero)
{
ShowWindow(hWnd, 0);
}
if(hWnd != IntPtr.Zero)
{
ShowWindow(hWnd, 1);
}
Have a Happy Coding.....
|
|
|
|
|
That makes the window minimised to the task bar, it does not hide the process.
Christian Graus
Driven to the arms of OSX by Vista.
"I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
|
|
|
|
|
Hi...
Just now checked the code myself....
It hides the console window named "CHECK".....
Check this code and leave a reply....
using System;
using System.Runtime.InteropServices;
namespace Loading
{
class loading
{
[DllImport("user32.dll")]
public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
[DllImport("user32.dll")]
static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
static void Main(string[] args)
{
Console.Title = "check";
Console.Write("Hello World");
IntPtr hWnd = FindWindow(null, "check");
if(hWnd != IntPtr.Zero)
{
ShowWindow(hWnd, 0);
}
Console.ReadLine();
if(hWnd != IntPtr.Zero)
{
ShowWindow(hWnd, 1);
}
Console.ReadLine();
}
}
}
Have a Happy Coding.....
|
|
|
|
|
Sorry, actually I wanted to just hide the processing Window, not the process. I know thats it impossible to hide a process. Thanx for pointing out my mistake.
|
|
|
|
|
You can't 'hide' a process. You want to hide the window. In that case, the answer you got is correct. Or just make it a windows app and make it run minimised.
Christian Graus
Driven to the arms of OSX by Vista.
"I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
|
|
|
|
|
ofcourse you cant.....
Eventhough the caption is wrongly given as Hiding the process, the question demands only to hide the window....
Have a Happy Coding.....
|
|
|
|
|
Just make your application as a service. Your application run in background without a window.
|
|
|
|