|
I am currently working on a number plate recognition project.My sotware is finding the plates from the images.Now in next task i want to grab the number plate and increase its size if its width and height is less then the certain threshold for better pixel information.In Visual C++ there is a function StretchBlt which serves the purpose but in CSharp i cannot find the way to Stretch(Increase Size)image.I have resized the image and displayed it on the screen.But i want to save to resize it and store it into Bitmap object at the backend.
|
|
|
|
|
<br />
using System.Drawing;<br />
using System.Drawing.Imaging;<br />
using System.Drawing.Drawing2D;<br />
<br />
<br />
void ResizeBitmap(Bitmap org, string filename, int width, int height)<br />
{<br />
Bitmap newBmp = new Bitmap(width, height);<br />
using (Graphics g = Graphics.FromImage(newBmp))<br />
{<br />
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
g.DrawImage(org, 0, 0, width, height);<br />
}<br />
<br />
newBmp.Save(filename, ImageFormat.Bmp);<br />
newBmp.Dispose();<br />
<br />
}<br />
|
|
|
|
|
Hello,
I have a situation that I have not been able to solve, maybe one of you can point me in a direction to pursue.
I have a Windows Form application that utilizies a RichTextBox to view the contents of a file. Some of the file have very lnog lines in them that initially need to be displayed for various reasons. For example, the first line may be 9,000 characters before its crlf is encountered.
The behavoir I'm getting in the RichTextBox is that it chops this line up on the display, so maybe at character 3,00o it wraps the line, then again at 2,800, then finally displays the remaining chunck of characters. So, I get the line displayed on 3 lines, although the line count is 1. If I open the file up in say Visual Studio or TextPad, it displays the contents all in 1 line, like I need it to.
I have set WordWrap to false.
Any ideas would be appreciated.
Thanks in advance.
|
|
|
|
|
Using the code from the DirectX.Capture project, I would like to read the mouse clicks and movements in the video preview panel. However, since the panel in the main form is overlayed with a new panel whenever Preview is active, the mouse movements on the original panel are unavailable. Is there a way to fetch the mouse movements in the "new" panel?
Thanks.
|
|
|
|
|
I would like to know how
to creat CDX index file for DBF Table.
thx
|
|
|
|
|
I have two forms (login and main). And as suggested on this forum, I load the login from my main form. So I have a modal login form infront of my main form. That is the way I want it but another problem emerged with the use of loginForm.ShowDialog(). If user clicks 'ok' and something is not right, I call a messageBox with an appropriate messsage; however, when I click 'ok' (on the message box) instead of bringing me back to the login form so I can retry loging in, application exits. It dosn't occure when I call loginForm.Show(), but this is not what I need. Please let me know where I'm going wrong.
Thank you
-- modified at 13:02 Monday 29th August, 2005
|
|
|
|
|
Build a loop (e.g. do-while-loop) that calls loginForm.ShowDialog and evaluates the DialogResult. If user clicks 'ok' and something is not right, show the message box and ensure that the loop is executed one more time (e.g. with a bool variable).
www.troschuetz.de
|
|
|
|
|
I was wondering why does the closing of the message box trigger the closing of the actual login form?
Thanx
|
|
|
|
|
Hmm, I guess I misunderstood your first posting a bit. Thought you check whether something is not right and call a messageBox after the ShowDialog method returned. Am I right that you do this inside of an event handler of the OK button?
Anyway, I think your login form automatically closes cause you set the DialogResult property of your OK button. If the value of this property is set to anything other than DialogResult.None , and if the form was displayed through the ShowDialog method, clicking the button closes the form without your having to hook up any events.
www.troschuetz.de
|
|
|
|
|
The code I'm working with was initially witten by someone else that is why I wasn't aware that DialogResult of the OK button was set to something. Your suggestion hit the spot. Thanks a lot.
|
|
|
|
|
|
hi all,
I have developed a application using C# and generate exe.(test.exe).But the problem is when I used a decompiller ,I can easily obtain the code again.Even though I convert this exe to class Library, It is also can decompile to get source code.
So How am I avoid this situation.How can I stop decompilling the .NET Application exe?
any answers greatly appreciated.
thanks in advance.
|
|
|
|
|
.Net languages 'compile' into an intermediate language (IL), and are only converted into machine code at runtime. There are obfuscation tools available that will scramble your IL in a manner that will make it difficult to reverse enginerr.
|
|
|
|
|
...finally available Goliath.NET - the last secure obfuscator for .NET Platform - the new plan all Italian who tries to stop the decompilation & reverse-engineering of the .NET assembly
thanks for your attention & best regards,
Marcello Cantelmo
www.cantelmosoftware.com
Nothing is Impossible if Not Tests the Absurdity !
|
|
|
|
|
Well I've gone through numerous examples and code samples here on the Code project as well as other places on the net and I just can't seem to get them to work properly. All I am trying to do is capture a screen shot of the entire desktop...INCLUDING all windows, programs & applications open on the desktop. The problem I am having is that whenever I take a screen shot, not all applications are captured. Currently I have an application that opens up several forms internally...as well as several IE Browsers. When I capture the screen the application is captured, but all of the forms and IE browsers that are overlaying the application are NOT captured. Almost as if they were all 'hidden' the screen shot was captured, then they were displayed again. Could someone please please help?? I'm just thoroughly confussed. Whenever I use the 'Print Screen' button the entire screen(s) contents are all captured perfectly, what am I doing wrong? Any and all help would be greatly appreciated, thanks so much. The code I am using is as follows...
public static Bitmap GetDesktopWindowCaptureAsBitmap()<br />
{<br />
Rectangle rcScreen = Rectangle.Empty;<br />
Screen[] screens = Screen.AllScreens;<br />
<br />
foreach(Screen screen in screens)<br />
rcScreen = Rectangle.Union(rcScreen, screen.Bounds);<br />
<br />
Bitmap finalBitmap = new Bitmap(rcScreen.Width, rcScreen.Height);<br />
<br />
Graphics g = Graphics.FromImage(finalBitmap);<br />
g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;<br />
g.FillRectangle(<br />
SystemBrushes.Desktop,<br />
0,<br />
0, <br />
rcScreen.Width - rcScreen.X, <br />
rcScreen.Height - rcScreen.Y);<br />
<br />
IntPtr hdcDestination = g.GetHdc();<br />
<br />
foreach(Screen screen in screens)<br />
{<br />
IntPtr hdcSource = Win32.CreateDC(<br />
IntPtr.Zero,<br />
screen.DeviceName,<br />
IntPtr.Zero,<br />
IntPtr.Zero);<br />
<br />
int xDest = screen.Bounds.X - rcScreen.X;<br />
int yDest = screen.Bounds.Y - rcScreen.Y;<br />
<br />
bool success = Win32.StretchBlt(<br />
hdcDestination,<br />
xDest,<br />
yDest, <br />
screen.Bounds.Width, <br />
screen.Bounds.Height, <br />
hdcSource, <br />
0, <br />
0, <br />
screen.Bounds.Width, <br />
screen.Bounds.Height, <br />
(int)Win32.TernaryRasterOperations.SRCCOPY);<br />
<br />
if (!success)<br />
{<br />
System.ComponentModel.Win32Exception win32Exception =<br />
new System.ComponentModel.Win32Exception(); <br />
System.Diagnostics.Trace.WriteLine(win32Exception);<br />
}<br />
<br />
Win32.DeleteDC(hdcSource); <br />
}<br />
<br />
g.ReleaseHdc(hdcDestination);<br />
g.Dispose();<br />
<br />
return finalBitmap;<br />
}
|
|
|
|
|
Are you capturing right after you create the windows? You have to give it several message loop iterations before it actually displays the windows.
Try putting the capture in a timer, set to say 100 msec or so. Be sure to turn it off right as the timer fires so that it only fires once, and be sure to use System.Windows.Forms.Timer (the one in the toolbox) so that you don't have threading issues.
|
|
|
|
|
Thanks for the input...I ended up using a different method to capture the screenshot. It worked perfectly, so it must have been something with the process I was using? I'm running a dual display (stretched desktop) for this application and wanted to make sure it worked across both screens...and it does indeed. Thanks again for the suggestions!!
For anyone interested...here was the solution I found on the net that worked great...though I modified it a little to fit in my project.
<br />
using System;<br />
using System.Drawing;<br />
using System.Drawing.Imaging;<br />
using System.Runtime.InteropServices;<br />
<br />
<br />
class GDI32<br />
{<br />
[DllImport("GDI32.dll")]<br />
public static extern bool BitBlt(int hdcDest,int nXDest,int nYDest,<br />
int nWidth,int nHeight,int hdcSrc,<br />
int nXSrc,int nYSrc,int dwRop);<br />
[DllImport("GDI32.dll")]<br />
public static extern int CreateCompatibleBitmap(int hdc,int nWidth,<br />
int nHeight);<br />
[DllImport("GDI32.dll")]<br />
public static extern int CreateCompatibleDC(int hdc);<br />
[DllImport("GDI32.dll")]<br />
public static extern bool DeleteDC(int hdc);<br />
[DllImport("GDI32.dll")]<br />
public static extern bool DeleteObject(int hObject);<br />
[DllImport("GDI32.dll")]<br />
public static extern int GetDeviceCaps(int hdc,int nIndex);<br />
[DllImport("GDI32.dll")]<br />
public static extern int SelectObject(int hdc,int hgdiobj);<br />
<br />
}<br />
class User32<br />
{<br />
[DllImport("User32.dll")]<br />
public static extern int GetDesktopWindow();<br />
[DllImport("User32.dll")]<br />
public static extern int GetWindowDC(int hWnd);<br />
[DllImport("User32.dll")]<br />
public static extern int ReleaseDC(int hWnd,int hDC);<br />
}<br />
<br />
<br />
namespace Example<br />
{<br />
public class capture<br />
{<br />
public capture()<br />
{<br />
}<br />
<br />
public void CaptureScreen(string fileName,ImageFormat imageFormat)<br />
{<br />
int hdcSrc = User32.GetWindowDC(User32.GetDesktopWindow()),<br />
hdcDest = GDI32.CreateCompatibleDC(hdcSrc),<br />
hBitmap = GDI32.CreateCompatibleBitmap(hdcSrc,<br />
GDI32.GetDeviceCaps(hdcSrc,8),GDI32.GetDeviceCaps(hdcSrc,10));<br />
GDI32.SelectObject(hdcDest,hBitmap);<br />
GDI32.BitBlt(hdcDest,0,0,GDI32.GetDeviceCaps(hdcSrc,8),<br />
GDI32.GetDeviceCaps(hdcSrc,10),<br />
hdcSrc,0,0,0x00CC0020);<br />
SaveImageAs(hBitmap,fileName,imageFormat);<br />
Cleanup(hBitmap,hdcSrc,hdcDest);<br />
<br />
return image;<br />
}<br />
<br />
private void Cleanup(int hBitmap,int hdcSrc,int hdcDest)<br />
{<br />
User32.ReleaseDC(User32.GetDesktopWindow(),hdcSrc);<br />
GDI32.DeleteDC(hdcDest);<br />
GDI32.DeleteObject(hBitmap);<br />
} <br />
<br />
private void SaveImageAs(int hBitmap,string fileName,ImageFormat imageFormat)<br />
{<br />
Bitmap image =<br />
new Bitmap(Image.FromHbitmap(new IntPtr(hBitmap)),<br />
Image.FromHbitmap(new IntPtr(hBitmap)).Width,<br />
Image.FromHbitmap(new IntPtr(hBitmap)).Height);<br />
image.Save(fileName,imageFormat);<br />
}<br />
}<br />
}<br />
|
|
|
|
|
You can simulate PrintScreen in your Program using
keybd_event API Function
This small program will take screen shot and display it in picture box
[DllImport("user32.dll")]
static extern void keybd_event(byte bVk, byte bScan, uint dwFlags,UIntPtr dwExtraInfo);
<code>private void btnPrintScreen_Click(object sender, System.EventArgs e)
{
keybd_event(44,0,0,UIntPtr.Zero);
IDataObject screen=Clipboard.GetDataObject();
if(screen.GetDataPresent(DataFormats.Bitmap))
{
pictureBox1.Image=(Image)screen.GetData(DataFormats.Bitmap,true);
}
}</code>
Note:
It use the Clipboard to get the image you can save the clipboard before printscreen and restore it after you get the image to get it back to its original state
MCAD
-- modified at 21:23 Monday 29th August, 2005
|
|
|
|
|
have received the following error a few times now :-
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************
System.NullReferenceException: Object reference not set to an instance of an object.
at test.tmrTimersTimer_Elapsed(Object sender, ElapsedEventArgs e) in C:\test\test.cs:line 1717
I have read how to enable JIT Debugging (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vsdebug/html/vxtskEnablingJust-in-TimeDebuggingForWindowsForms.asp[^]).
I have created MyApp.exe.config, machine.config with the following
?xml version="1.0" encoding="utf-8" ?
configuration
system.windows.forms jitDebugging="true"
configuration
NOTE < and > have been removed to allow posting
I have placed them in the same folder as my .sln file and also in the same folder as .exe. But it does not seem to work. By the way I am using a setup project to install this applicaiton is there anything special I have to do in the setup project to allow JIT debugging on the installed machine?
Anyone have any idea what I am doing wrong? I would like to enable JIT debugging permanently.
Thanks,
Liam
|
|
|
|
|
Hi,
I'm planning to build an application. It will dispaly a office layout map. What I want to do is:
1. Is it possible to auto detect each room?
2. If not, I'm planning to mark each room by using rectangle or polygon manually. After marked, the information should be stored.
3. Next time when the map is loaded, the marked area should be highlighted and blinked.
4. When the map resized, the stored mark information should still work.
Can anyone who is an expert in graphice give me some clue?
Thanks
|
|
|
|
|
1) You're joking, right?
2, 3, 4) There's no question here. There really not much in the way of graphics to this. This is mostly just data objects representing rooms, floors, whatever, ..., that will probably draw themselves. If you want to save the layout, you'll have to serialize the object your using to a file. When the map is resized, the objects should redraw themselves. Whether or not they still work after being resized is not an issue here.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Dear Dave,
Thanks for your message.
I'm new to C#. The above are just my thought based on my IT knowlwdge. I appreciate if you can provide more information on how to do 2, 3, 4. Some sample code will be nice and helpful to me.
Thanks in advance.
|
|
|
|
|
I don't have any sample code. I can just picture how it would work in my head and generate a rough design from that.
The most important part of this is the data model, not the drawing. You don't even need drawing at this point. Just model the data that you want to handle. Do some research on Serialization to XML files. You need to save your objects then reload them from the files.
When you have this working, then you can add to it, like drawing code. You'll need to add position and size data to your objects. They will also need to be able to take a Graphics object as a parameter to a Draw method that you'll have to write. What you draw in this is entirely up to you. If you have no idea how to draw anything in Windows, Google for articles on "Drawing Windows Graphics C#" and learn the basics before you attempt to do this.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I'm using the System.Net.Sockets class to set and retrieve information from a socket. I am running into a problem because a half second delay is needed before the response can be read. Any ideas why this delay is needed and how it can be avoided? Thank you,
Jason W.
|
|
|
|
|
I'd like to know if there is a way to send clicks to the other applications.
At least to send a click to the window behind my app's window.
thanks in advance to all helpers!
[ITA] Tozzi ha ragione: Gaia si sta liberando di noi.
[ENG] Tozzi is right: Gaia is obliterating us.
|
|
|
|
|