Wing
Members-
Posts
15 -
Joined
-
Last visited
About Wing
- Birthday 05/03/1987
Personal Information
-
Occupation
Student
-
Visual Studio .NET Version
Visual Studio .NET Professional
-
.NET Preferred Language
C#
Wing's Achievements
Newbie (1/14)
0
Reputation
-
Hi im trying to write a simpel ftp upload program... iv been trying to use the FtpWebRequest but well every time i wanna do some thing i have to create a new instance of the class and so a new connection to the server... is there any user written ftp class that manages this in a better way? Tnx alot!
-
Iv found a way to fix the problem :P iv changed GDI32.BitBlt(hdcDest, 0, 0, width, height, hdcSrc, 0, 0, GDI32.SRCCOPY); to: GDI32.BitBlt(hdcDest, 0, 0, width, height, hdcSrc, 0, 0, GDI32.SRCCOPY | GDI32.CAPTUREBLT); and added public const int CAPTUREBLT = 1073741824; to the GDI32 class
-
Well sure i could do that but that didnt slove the problem i still get no tool tips in the image it results...
-
Hi i use this class to take a screen capture but i want to include small yellow tooltips in my screen shot how do i do that?, if you press print screen then you get em in the picture so there should be a way? public class ScreenCapture { /// <summary> /// Creates an Image object containing a screen shot of the entire desktop /// </summary> /// <returns></returns> public Image CaptureScreen() { return CaptureWindow(User32.GetDesktopWindow()); } /// <summary> /// Creates an Image object containing a screen shot of a specific window /// </summary> /// <param name="handle">The handle to the window. (In windows forms, this is obtained by the Handle property)</param> /// <returns></returns> private Image CaptureWindow(IntPtr handle) { // get te hDC of the target window IntPtr hdcSrc = User32.GetWindowDC(handle); // get the size User32.RECT windowRect = new User32.RECT(); User32.GetWindowRect(handle, ref windowRect); int width = windowRect.right - windowRect.left; int height = windowRect.bottom - windowRect.top; // create a device context we can copy to IntPtr hdcDest = GDI32.CreateCompatibleDC(hdcSrc); // create a bitmap we can copy it to, // using GetDeviceCaps to get the width/height IntPtr hBitmap = GDI32.CreateCompatibleBitmap(hdcSrc, width, height); // select the bitmap object IntPtr hOld = GDI32.SelectObject(hdcDest, hBitmap); // bitblt over GDI32.BitBlt(hdcDest, 0, 0, width, height, hdcSrc, 0, 0, GDI32.SRCCOPY); // restore selection GDI32.SelectObject(hdcDest, hOld); // clean up GDI32.DeleteDC(hdcDest); User32.ReleaseDC(handle, hdcSrc); // get a .NET image object for it Image img = Image.FromHbitmap(hBitmap); // free up the Bitmap object GDI32.DeleteObject(hBitmap); return img; } /// <summary> /// Helper class containing Gdi32 API functions /// </summary> private class GDI32 { public const int SRCCOPY = 0x00CC0020; // BitBlt dwRop parameter [DllImport("gdi32.dll")] public static extern bool BitBlt(IntPtr hObject, int nXDest, int nYDest, int nWidth, int nHeight, IntPtr hObjectSource, int nXSrc, int nYSrc, int dwRop); [DllImport("gdi32.dll")] public static extern IntPtr CreateCompatibleBitmap(IntPtr hDC, int nWidth, int nHeight); [DllImport("gdi32.dll")] public static extern IntPtr CreateCompatibleDC(IntPtr hDC); [DllImport("gdi32.dll")] public static extern bool DeleteDC(IntPtr hDC); [DllImport("gdi32.dll")] public static extern bool DeleteObject(IntPtr hObject); [DllImport("gdi32.dll")] public static extern IntPtr SelectObject(IntPtr hDC, IntPtr hObject); } /// <summary> /// Helper class containing User32 API functions /// </summary> private class User32 { [structLayout(LayoutKind.Sequential)] public struct RECT { public int left; public int top; public int right; public int bottom; } [DllImport("user32.dll")] public static extern IntPtr GetDesktopWindow(); [DllImport("user32.dll")] public static extern IntPtr GetWindowDC(IntPtr hWnd); [DllImport("user32.dll")] public static extern IntPtr ReleaseDC(IntPtr hWnd, IntPtr hDC); [DllImport("user32.dll")] public static extern IntPtr GetWindowRect(IntPtr hWnd, ref RECT rect); } }
-
Splitting one Image into a d2 image array, help!
Wing replied to Wing's topic in Graphics and Multimedia
Re: DrawImage well that was my first try to use GDI, but as i said it didnt turn out so well when i copy with blitblt the result is black and i still dont know why >.<... -
Splitting one Image into a d2 image array, help!
Wing replied to Wing's topic in Graphics and Multimedia
Re: DrawImage Tnx alot looks like it works!!, but its extremely slow is there any way to speed it up? I found bitblt but i cant get it to work the result is just black.... any way here is my bitblt code: public Image[,] SplitImage(Image image, int rows, int columns) { Image[,] images = new Image[rows, columns]; for (int row = 0; row < rows; row++) { for (int colum = 0; colum < columns; colum++) { //UnManaged way using (Graphics sourceG = Graphics.FromImage(image)) { int width = image.Width / rows; int height = image.Height / columns; // get te hDC of the target IntPtr hdcSrc = sourceG.GetHdc(); // create a device context we can copy to IntPtr hdcDest = GDI32.CreateCompatibleDC(hdcSrc); // create a bitmap we can copy it to, // using GetDeviceCaps to get the width/height IntPtr hBitmap = GDI32.CreateCompatibleBitmap(hdcSrc, width, height); // select the bitmap object IntPtr hOld = GDI32.SelectObject(hdcDest, hBitmap); // bitblt over GDI32.BitBlt(hdcDest, 0, 0, width, height, hdcSrc, width * row, height * colum, GDI32.SRCCOPY); // restore selection GDI32.SelectObject(hdcDest, hOld); // clean up GDI32.DeleteDC(hdcDest); sourceG.ReleaseHdc(hdcSrc); // get a .NET image object for it images[row, colum] = Image.FromHbitmap(hBitmap); // free up the Bitmap object GDI32.DeleteObject(hBitmap); } } } return images; } private class GDI32 { public const int SRCCOPY = 0x00CC0020; // BitBlt dwRop parameter [DllImport("gdi32.dll")] public static extern bool BitBlt(IntPtr hObject, int nXDest, int nYDest, int nWidth, int nHeight, IntPtr hObjectSource, int nXSrc, int nYSrc, int dwRop); [DllImport("gdi32.dll")] public static extern IntPtr CreateCompatibleBitmap(IntPtr hDC, int nWidth, int nHeight); [DllImport("gdi32.dll")] public static extern IntPtr CreateCompatibleDC(IntPtr hDC); [DllImport("gdi32.dll")] public static extern bool DeleteDC(IntPtr hDC); [DllImport("gdi32.dll")] public static extern bool DeleteObject(IntPtr hObject); [DllImport("gdi32.dll")] public static extern IntPtr SelectObject(IntPtr hDC, IntPtr hObject); } -
Hi im trying to write a function to split one image into a d2 image array well i got this far public Image[,] SplitImages(Image image, int rows, int columns) { Image[,] images = new Image[rows, columns]; for (int row = 0; row < rows; row++) { for (int colum = 0; colum < columns; colum++) { images[row, colum] = new Bitmap(image.Width/rows,image.Height/columns); Graphics g = Graphics.FromImage(images[row, colum]); g.DrawImageUnscaled(image, (image.Width / rows) * row, (image.Height / columns) * colum, (image.Width / rows), (image.Height / columns)); } } return images; } But only the first([0,0]) image in the array works the rest of them just turn blank i dont get why or if i did do any thing wrong.. Tnx for any help you can offer!!
-
I dont know if you can do that but feel free to look up in the rfc: http://www.w3.org/Protocols/rfc959/
-
Tnx marble_eater ill try some of the stuff out you wrote..
-
Tnx alot that speeded it up a bit atleast..
-
Hi well i made my first try to make a file browser but its SLOW it might be the logic im using... is there any faster better way to make this work? would be greatfull for any help!!! here is the code i wrote: private void Form1_Load(object sender, EventArgs e) { AddDrivers(DrivertreeView); } private void AddDrivers(TreeView TreeViewControl) { DriveInfo[] DriverInfos = DriveInfo.GetDrives(); foreach (DriveInfo Driveinfo in DriverInfos) { if (Driveinfo.Name != @"A:\") { Icon i = ShellIcon.GetSmallIcon(Driveinfo.Name); SmallIconimageList.Images.Add(Driveinfo.Name, i); TreeNode node = TreeViewControl.Nodes.Add(Driveinfo.Name, Driveinfo.Name, Driveinfo.Name, Driveinfo.Name); DirectoryInfo Directoryinfo = new DirectoryInfo(Driveinfo.Name); try { AddFolders(TreeViewControl, Directoryinfo, node); } catch (Exception E) { Trace.WriteLine(E.Message); } } } } private void AddFolders(TreeView TreeViewControl, DirectoryInfo directory,TreeNode node) { DirectoryInfo[] DirectoryInfos; try { DirectoryInfos = directory.GetDirectories(); } catch(Exception) { return; } foreach (DirectoryInfo DI in DirectoryInfos) { Trace.WriteLine(DI.FullName); Icon i = ShellIcon.GetSmallIcon(DI.FullName); SmallIconimageList.Images.Add(DI.FullName, i); node.Nodes.Add(DI.Name, DI.Name, DI.FullName, DI.FullName); } } private void AddFiles(ListView listView,DirectoryInfo directory) { listView.Items.Clear(); FileInfo[] Files = directory.GetFiles(); foreach (FileInfo file in Files) { Icon i = ShellIcon.GetSmallIcon(file.FullName); SmallIconimageList.Images.Add(file.FullName, i); i = ShellIcon.GetLargeIcon(file.FullName); LargeIconimageList.Images.Add(file.FullName, i); listView.Items.Add(file.Name, file.FullName); } } private void DrivertreeView_BeforeExpand(object sender, TreeViewCancelEventArgs e) { foreach (TreeNode node in e.Node.Nodes) { Trace.WriteLine(node.FullPath); AddFolders(DrivertreeView, new DirectoryInfo(node.FullPath), node); } } private void DrivertreeView_BeforeSelect(object sender, TreeViewCancelEventArgs e) { AddFiles(FileslistView, new DirectoryInfo(e.Node.FullPath)); } WindowsApplication4.zip
-
When you redirect you could just add ?Criteria=blabla, and then just read the variable on the other end?
-
Hi, well i need to compare to images and iv found a way but was wondering if there is any faster way to do it.. any way here is my code: public static bool CompareImage(Image img1, Image img2) { //Test to see if we have the same size of image if (img1.Size != img2.Size) { return false; } else { //Convert each image to a byte array System.Drawing.ImageConverter ic = new System.Drawing.ImageConverter(); byte[] btImage1 = new byte[1]; btImage1 = (byte[])ic.ConvertTo(img1, btImage1.GetType()); byte[] btImage2 = new byte[1]; btImage2 = (byte[])ic.ConvertTo(img2, btImage2.GetType()); for (int i = 0; i < btImage1.Length; i++) { if (btImage1[i] != btImage2[i]) { return false; } } } return true; }
-
Tnx alot ill try it out.
-
Well here is my problem i got a multi thread/form project. and if i try to use the clipboard on any other from then the "start form" i get a thread error.... sample code included. Tnx for any help! PlayWithForms.zip