Search Results

Search found 148 results on 6 pages for 'picturebox'.

Page 2/6 | < Previous Page | 1 2 3 4 5 6  | Next Page >

  • Save the zoomed image on Picturebox control using C#

    - by Vinay G
    Hi I had posted this question before but i did not get the answer Proper(i think people did not get my question ) so i am posting it now. I capture a image from windows mobile camera and save it on picturebox control..now to zoom the picture i am increasing its size by Onpaint event.The image is getting zoomed but i am not able to save the zoomed image(ie.., the increased image size)... Please let me know Thanks In Advance

    Read the article

  • retrieve image from sql server in picturebox

    - by user3116296
    I have saved a picture in sql server and now i can not to retrieve image and set it's in picturebox with linq. why byte[] x become null? private void dataGridViewUser_CellClick(object sender, DataGridViewCellEventArgs e) { DataGridViewRow row = dataGridViewUser.CurrentRow; byte[] x=(byte[])row.Cells["Image"].Value; MemoryStream ms1 = new MemoryStream(x); picuser.Image = Bitmap.FromStream(ms1); }

    Read the article

  • WCF/REST Get image into picturebox?

    - by Garrith
    So I have wcf rest service which succesfuly runs from a console app, if I navigate to: http://localhost:8000/Service/picture/300/400 my image is displayed note the 300/400 sets the width and height of the image within the body of the html page. The code looks like this: namespace WcfServiceLibrary1 { [ServiceContract] public interface IReceiveData { [OperationContract] [WebInvoke(Method = "GET", BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Xml, UriTemplate = "picture/{width}/{height}")] Stream GetImage(string width, string height); } public class RawDataService : IReceiveData { public Stream GetImage(string width, string height) { int w, h; if (!Int32.TryParse(width, out w)) { w = 640; } // Handle error if (!Int32.TryParse(height, out h)) { h = 400; } Bitmap bitmap = new Bitmap(w, h); for (int i = 0; i < bitmap.Width; i++) { for (int j = 0; j < bitmap.Height; j++) { bitmap.SetPixel(i, j, (Math.Abs(i - j) < 2) ? Color.Blue : Color.Yellow); } } MemoryStream ms = new MemoryStream(); bitmap.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); ms.Position = 0; WebOperationContext.Current.OutgoingResponse.ContentType = "image/jpeg"; return ms; } } } What I want to do now is use a client application "my windows form app" and add that image into a picturebox. Im abit stuck as to how this can be achieved as I would like the width and height of the image from my wcf rest service to be set by the width and height of the picturebox. I have tryed this but on two of the lines have errors and im not even sure if it will work as the code for my wcf rest service seperates width and height with a "/" if you notice in the url. string uri = "http://localhost:8080/Service/picture"; private void button1_Click(object sender, EventArgs e) { StringBuilder sb = new StringBuilder(); sb.AppendLine("<picture>"); sb.AppendLine("<width>" + pictureBox1.Image.Width + "</width>"); // the url looks like this http://localhost:8080/Service/picture/300/400 when accessing the image so I am trying to set this here sb.AppendLine("<height>" + pictureBox1.Image.Height + "</height>"); sb.AppendLine("</picture>"); string picture = sb.ToString(); byte[] getimage = Encoding.UTF8.GetBytes(picture); // not sure this is right HttpWebRequest req = WebRequest.Create(uri); //cant convert webrequest to httpwebrequest req.Method = "GET"; req.ContentType = "image/jpg"; req.ContentLength = getimage.Length; MemoryStream reqStrm = req.GetRequestStream(); //cant convert IO stream to IO Memory stream reqStrm.Write(getimage, 0, getimage.Length); reqStrm.Close(); HttpWebResponse resp = req.GetResponse(); // cant convert web respone to httpwebresponse MessageBox.Show(resp.StatusDescription); pictureBox1.Image = Image.FromStream(reqStrm); reqStrm.Close(); resp.Close(); } So just wondering if some one could help me out with this futile attempt at adding a variable image size from my rest service to a picture box on button click. This is the host app aswell: namespace ConsoleApplication1 { class Program { static void Main(string[] args) { string baseAddress = "http://" + Environment.MachineName + ":8000/Service"; ServiceHost host = new ServiceHost(typeof(RawDataService), new Uri(baseAddress)); host.AddServiceEndpoint(typeof(IReceiveData), new WebHttpBinding(), "").Behaviors.Add(new WebHttpBehavior()); host.Open(); Console.WriteLine("Host opened"); Console.ReadLine();

    Read the article

  • Get Taskbar's Battery and PhoneSignal indicators icons and draw into a picturebox (C#/WindowsMobile)

    - by Christian Almeida
    Hi, Is there any way to get taskbar's battery and phonesignal indicators icons and then draw into a picturebox or something? Why do I need this? I need all screen space available, so all forms are maximized and they cover up the windowsmobile taskbar. But, I have to display information about battery e phone signal strength in just a couple of forms. I know how to get their values (like systeminformation.phonesignalstrength), but what I want is the "current icon", so I don't need to worry about their values. It's just a visual information for the user. In last case, if this is not possible, how to get those icons from windowsmobile shell, so I'll draw them by my self, treating each differente status/values that they assume. (This is what I don't want to do!) Thanks in advance and sorry for my poor english.

    Read the article

  • Copying a 14bit grayscale image (saved in long[]) to a pictureBox

    - by Itsik
    My camera gives me 14bit grayscale images, but the API's function returns a long* to the image data. (so i'm assuming 4 bytes for each pixel) My application is written in C++/CLI, and the pictureBox is of .NET type. I am currently using the BitmapData.LockBits() mechanism to gain pointer access to the image data, and using memcpy(bmpData.Scan0.ToPointer(), imageData, sizeof(long)*height*width) to copy the image data to the Bitmap. For now, the only PixelFormat that is working is 32bit RGB, and the image appears in shades of blue with contours. Trying to initialize the Bitmap as 16bppGrayscale isn't working. I would ideally want to cast the array from long to word and using a 16bit format (hoping the the 14bit data will be displayed properly) but I'm not sure if this works. Also, I don't want to iterate over the image data, so finding the min/max and then histogram stretching to [0..255] isnt an option for me (the display must be as efficient as possible) Thanks

    Read the article

  • Can't draw to a pictureBox in a loop

    - by Jason94
    I have a List<Point> where Point contains X and Y. What i want is to loop a list like that and draw a line point to point, i do so by: foreach (List<Point> wps in map.waypoints) { System.Drawing.Pen myPen; myPen = new System.Drawing.Pen(System.Drawing.Color.Black); System.Drawing.Graphics formGraphics = this.pictureBox1.CreateGraphics(); Point startPos = new Point(wps[0].X, wps[0].Y); foreach (Point p in wps) { formGraphics.DrawLine(myPen, startPos.X, startPos.Y, p.X, p.Y); startPos = p; } myPen.Dispose(); formGraphics.Dispose(); } BUT nothing gets drawn! I did the same with the on_click event to the pictureBox but instead if a looping some Points ive just used mouse X and Y. I have verified the lists of points that they dont contain rubish :D

    Read the article

  • image list, listview,picturebox

    - by user548694
    I wanted to show my pics in picturebox. but also wanted to show a preview of pics. When user select a pic, it is shown in picbox but i have problem in resoulution. Here is my code private void openToolStripMenuItem_Click(object sender, EventArgs e) { ofd = new OpenFileDialog(); ofd.Title = "Open an Image File"; ofd.FileName = ""; ofd.Filter = "Image Files(*.jpg; *.jpeg; *.gif; *.bmp)|*.jpg; *.jpeg; *.gif; *.bmp"; if (ofd.ShowDialog() == DialogResult.OK) { DirectoryInfo dir = new DirectoryInfo(@"c:\pic"); foreach (FileInfo file in dir.GetFiles()) { this.imageList1.Images.Add(Image.FromFile(file.FullName)); } this.listView1.View = View.LargeIcon; this.imageList1.ImageSize = new Size(40, 40); this.listView1.LargeImageList = this.imageList1; for (int j=0; j < this.imageList1.Images.Count; j++) { ListViewItem item = new ListViewItem(); item.ImageIndex = j; listView1.Items.Add(item); ListViewItem item2 = new ListViewItem(); item2.SubItems.Add(j.ToString()); } private void listView1_SelectedIndexChanged(object sender, EventArgs e) { int i = this.listView1.FocusedItem.Index; this.PicBox1.Image = this.imageList1.Images[i]; } On click i see only image of resolution of (40,40) becuse i have set it this.imageList1.ImageSize = new Size(40, 40); and not orignal size. How can I have it. 2- I want to write also image names and index(image no) under each images. Its it possible. reagrsd,

    Read the article

  • c# Dynamically generated controls issue.

    - by Thomas
    Good Day I have a form with a panel docked in it. I then dynamically create 15 panels (named: panel_n) and 15 pictureboxes (named: picturebox_n) on the primary panel (named ContainerPanel). When dragging the any picturebox over a panel (panel_n) created using the relevant mouse events. I would like to get the panel's name that the picture box was dragged over. The mouse cursor seems to be captured. I have tried creating a IMessageFilter interface, but there are still no events that trigger when dragging one of the pictureboxes over any one of the panels. The ClientRectangle.IntersectsWith function also does not work as the co-ords are always 0,0. All I need is the panel name where the picturebox was dragged over (preferably on the mouseup event)

    Read the article

  • Dynamically generated controls issue.

    - by Thomas
    I have a form with a panel docked in it. I then dynamically create 15 panels (named: panel_n) and 15 pictureboxes (named: picturebox_n) on the primary panel (named ContainerPanel). When dragging the any picturebox over a panel (panel_n) created using the relevant mouse events. I would like to get the panel's name that the picture box was dragged over. The mouse cursor seems to be captured. I have tried creating a IMessageFilter interface, but there are still no events that trigger when dragging one of the pictureboxes over any one of the panels. The ClientRectangle.IntersectsWith function also does not work as the co-ords are always 0,0. All I need is the panel name where the picturebox was dragged over (preferably on the mouseup event)

    Read the article

  • saved image in the picturebox shows no preview

    - by Nivas
    Hi iam new to C# and have loaded the image in the picture box using menustrip and have displayed some text using picturebox_Paint and label. now i tried to save the image (with image and text) using save event from the menustrip. in the saved location the file shows as no preview avaliable and when i tried to open the file it shows out of memory. can any one say where iam going worng.... my coades private void openToolStripMenuItem_Click(object sender, EventArgs e) { string file = ""; OpenFD.FileName = ""; OpenFD.Title = "open image"; OpenFD.InitialDirectory = "C"; OpenFD.Filter = "JPEG|.jpg|Bmp|.bmp|All Files|..*"; if (OpenFD.ShowDialog() == DialogResult.OK) { file = OpenFD.FileName; pictureBox1.Image = Image.FromFile(file); sz = pictureBox1.Size; a=sz.Width; b= sz.Height; } private void pictureBox1_MouseMove(object sender, MouseEventArgs e) { switch (e.Button) { case MouseButtons.Left: { rect = new Rectangle(rect.Left, rect.Top, e.X - rect.Left, e.Y - rect.Top); this.Invalidate(); y = flag.e; Application.DoEvents(); break; } } } private void pictureBox1_MouseDown(object sender, MouseEventArgs e) { rect = new Rectangle(e.X, e.Y, 0, 0); this.Invalidate(); } private void pictureBox1_Paint(object sender, PaintEventArgs e) { using (Pen pen = new Pen(Color.Red, 2)) e.Graphics.DrawRectangle(pen, rect); //e.Graphics.DrawString(label1.Text, label1.Font, new // SolidBrush(label1.ForeColor), label1.Left - pictureBox1.Left, label1.Top - pictureBox1.Top); if (label1.TextAlign == ContentAlignment.TopLeft) { e.Graphics.DrawString(label1.Text, label1.Font, new SolidBrush(label1.ForeColor), label1.Bounds); } else if (label1.TextAlign == ContentAlignment.TopCenter) { SizeF size = e.Graphics.MeasureString(label1.Text, label1.Font); float left = ((float)this.Width + label1.Left) / 2 - size.Width / 2; RectangleF rect1 = new RectangleF(left, (float)label1.Top, size.Width, label1.Height); e.Graphics.DrawString(label1.Text, label1.Font, new SolidBrush(label1.ForeColor), rect1); } else { SizeF size = e.Graphics.MeasureString(label1.Text, label1.Font); float left = (float)label1.Width - size.Width + label1.Left; RectangleF rect1 = new RectangleF(left, (float)label1.Top, size.Width, label1.Height); e.Graphics.DrawString(label1.Text, label1.Font, new SolidBrush(label1.ForeColor), rect1); } label1.Top = rect.Top; label1.Left = rect.Left; label1.Width = rect.Width; label1.Height = rect.Height; } private void saveToolStripMenuItem_Click(object sender, EventArgs e) { SaveFileDialog SaveFD1 = new SaveFileDialog(); //string Sd_file = ""; SaveFD1.FileName = ""; SaveFD1.InitialDirectory = "C"; SaveFD1.Title = "save file Name"; SaveFD1.Filter= "JPG|.jpg|Bmp|.bmp"; if (SaveFD1.ShowDialog() != DialogResult.Cancel) { System.IO.Stream filename = (System.IO.FileStream)SaveFD1.OpenFile(); if (SaveFD1.Filter == "JPG") pictureBox1.Image.Save(SaveFD1.FileName); //pictureBox1.Image.Save (filename, System.Drawing.Imaging.ImageFormat.Jpeg); else if (SaveFD1.Filter == "Bmp") { //pictureBox1.Image.Save(filename, System.Drawing.Imaging.ImageFormat.Bmp); } filename.Close(); } }

    Read the article

  • mouse event on picturebox

    - by user548694
    I want to see my pixel coordinates on moviing my mouse on the image in picture box I have added this event Form.designer.cs this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pictureBox1_MouseDown); and this method in Form.cs private void pictureBox1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) { locationtxt.Text = e.X.ToString() + "," + e.Y.ToString(); } but I cann't see anything in textbox on moving my mouse on form runtime. What should i add further. regards,

    Read the article

  • How do i make a picturebox selectable?

    - by acidzombie24
    I am making a very basic map editor. I'm halfway through it and one problem i hit is how to delete an object. I would like to press delete but there appears to be no keydown event for pictureboxes and it will seem like i will have it only on my listbox. What is the best solution for deleting an object in my editor?

    Read the article

  • C# WinForms: How to load an image, then wait a few seconds, then play a mp3 sound ?

    - by ibmkahm
    Hello everybody, (after pressing a button) i would like to show an image (using a picturebox), wait a few seconds and then play a mp3 sound, but i dont get it to work. To wait a few seconds i use "System.Threading.Thread.Sleep(5000)". The problem is, the image alway appears AFTER the wait time, but i want it to show first, then wait, then play the mp3... i tried to use "WaitOnLoad = true" but it doesnt work, shouldn't it load the image first and the continue to read the next code line ?? Here is the code i've tried, that doesnt work: private void button1_Click(object sender, EventArgs e) { pictureBox1.WaitOnLoad = true; pictureBox1.Load("image.jpg"); System.Threading.Thread.Sleep(5000); MessageBox.Show("test"); //just to test, here should be the code to play the mp3 } (i also tried loading the image with "LoadAsync" and put the code to wait and play the mp3 in the "LoadCompleted" event, but that doesnt work either...) would be very nice if somebody helps me

    Read the article

  • Image animation stops on minimizing and restoring

    - by lc
    I have a .NET WinForms application with an animated GIF in a PictureBox. It's a loading animation, shown while a BackgroundWorker does some processing in another thread. I load the image by setting the Image property and it animates on its own. All is fine until I minimize and restore the application. At which point, the image stops animating and just displays whatever frame it was last on. Note that: The background thread still runs fine and none of the "business" of the application is affected. Subsequently-displayed animated GIFs do work fine (unless the application is minimized again). Does anyone know what causes this problem? Any workarounds?

    Read the article

  • Creating a image viewer window controll.

    - by Scott Chamberlain
    I am learning GDI+ and I am trying to make a display window with scroll bars (so I can only see part of the image at a time and I can scroll around it). I have read through the basics of GDI+ from several books but I have not found any good tutorials online or in books available to me about doing more advanced things like this. Any recommendations on guides or example code on how do do this? Here is what I have so far protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); if (Label != null) { using (Bitmap drawnLabel = new Bitmap(Label.LabelHeight, Label.LableLength, System.Drawing.Imaging.PixelFormat.Format1bppIndexed)) using (Graphics drawBuffer = Graphics.FromImage(drawnLabel)) { drawBuffer.ScaleTransform(_ImageScaleFactor, _ImageScaleFactor); foreach (Epl2.IDrawableCommand cmd in Label.Collection) { cmd.Paint(drawBuffer); } drawBuffer.ResetTransform(); } } } I would like to paint this in to a PictureBox I have on the control and control what is shown by a VScrollBar and HScrollBar but I don't know how to do that step. P.S. Label is a custom class that I have in my namespace, it is a object that represents a label you would print from a label printer.

    Read the article

  • drag to pan on an UserControl

    - by Matías
    Hello, I'm trying to build my own "PictureBox like" control adding some functionalities. For example, I want to be able to pan over a big image by simply clicking and dragging with the mouse. The problem seems to be on my OnMouseMove method. If I use the following code I get the drag speed and precision I want, but of course, when I release the mouse button and try to drag again the image is restored to its original position. using System.Drawing; using System.Windows.Forms; namespace Testing { public partial class ScrollablePictureBox : UserControl { private Image image; private bool centerImage; public Image Image { get { return image; } set { image = value; Invalidate(); } } public bool CenterImage { get { return centerImage; } set { centerImage = value; Invalidate(); } } public ScrollablePictureBox() { InitializeComponent(); SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer, true); Image = null; AutoScroll = true; AutoScrollMinSize = new Size(0, 0); } private Point clickPosition; private Point scrollPosition; protected override void OnMouseDown(MouseEventArgs e) { base.OnMouseDown(e); clickPosition.X = e.X; clickPosition.Y = e.Y; } protected override void OnMouseMove(MouseEventArgs e) { base.OnMouseMove(e); if (e.Button == MouseButtons.Left) { scrollPosition.X = clickPosition.X - e.X; scrollPosition.Y = clickPosition.Y - e.Y; AutoScrollPosition = scrollPosition; } } protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); e.Graphics.FillRectangle(new Pen(BackColor).Brush, 0, 0, e.ClipRectangle.Width, e.ClipRectangle.Height); if (Image == null) return; int centeredX = AutoScrollPosition.X; int centeredY = AutoScrollPosition.Y; if (CenterImage) { //Something not relevant } AutoScrollMinSize = new Size(Image.Width, Image.Height); e.Graphics.DrawImage(Image, new RectangleF(centeredX, centeredY, Image.Width, Image.Height)); } } } But if I modify my OnMouseMove method to look like this: protected override void OnMouseMove(MouseEventArgs e) { base.OnMouseMove(e); if (e.Button == MouseButtons.Left) { scrollPosition.X += clickPosition.X - e.X; scrollPosition.Y += clickPosition.Y - e.Y; AutoScrollPosition = scrollPosition; } } ... you will see that the dragging is not smooth as before, and sometimes behaves weird (like with lag or something). What am I doing wrong? I've also tried removing all "base" calls on a desperate movement to solve this issue, haha, but again, it didn't work. Thanks for your time.

    Read the article

  • What is faster with PictureBox? Many small redraws or complete redraw.

    - by kornelijepetak
    I have a PictureBox (WinMobile 6 WinForm) on which I draw some images. There is a background image that goes in the background and it does not change. However objects that are drawn on the picturebox are moving during the application so I need to refresh the background. Since items that are redrawn fill from 50% to 80% of the surface, the question is which of the two is faster: 1) Redraw only parts of the background image that have been changed (previous+next location of the moving object). 2) Redraw complete background and then draw all the objects in their current position. Now, the reason for asking is because I am not sure how much of processor power is needed for a single drawImage operation and what are the time consuming factors. I am aware if there is almost complete coverage of the background, it would be stupid to redraw portions of it, because by drawing portions I will have drawn the complete picture. But since sometimes only half of the image had changed (some objects remained in their old position), it may (perhaps) be benefitial to redraw only those regions. But I need your insight on this... Thanks.

    Read the article

  • C#: Windows Forms: Getting keystrokes in a panel/picturebox?

    - by Rosarch
    I'm making a level editor for a game using windows forms. The form has several drop down menus, text boxes, etc, where the user can type information. I want to make commands like CTRL + V or CTRL + A available for working within the game world itself, not text manipulation. The game world is represented by a PictureBox contained in a Panel. This event handler isn't ever firing: private System.Windows.Forms.Panel canvas; // ... this.canvas = new System.Windows.Forms.Panel(); // ... this.canvas.PreviewKeyDown += new System.Windows.Forms.PreviewKeyDownEventHandler(this.canvas_PreviewKeyDown); What is the preferred way of doing this? Can a panel even receive keyboard input? I would like to allow the user to use copy/paste/select-all commands when working with the text input, but not when placing objects in the game world.

    Read the article

  • How can I draw a Rectangle on a PictureBox?

    - by TooFat
    I am trying to just draw a Rectangle on a PictureBox that is on a Form. Writing text like shown here works fine. private void pictureBox1_Paint(object sender, PaintEventArgs e) { using (Font myFont = new Font("Arial", 14)) { e.Graphics.DrawString("Hello .NET Guide!", myFont, Brushes.Green, new Point(2, 2)); } } but when I try to draw a rectangle like so nothing shows up. private void pictureBox1_Paint(object sender, PaintEventArgs e) { Rectangle rect = new Rectangle(); rect.Location = new Point(25, 25); rect.Width = 50; using (Pen pen = new Pen(Color.Red, 2)) { e.Graphics.DrawRectangle(pen, rect); } } What am I missing?

    Read the article

  • If I replace an image in a PictureBox control, should I dispose the original image first? .Net Winfo

    - by Jules
    Following on from my question here http://stackoverflow.com/questions/2548664/long-overdue-for-me-question-about-disposing-managed-objects-in-net-vb-net , If I replace an image in a picture box, should I dispose the original image first? Or, what about this situation: Dim bm As New Bitmap(32,32) bm = New Bitmap(32,32) bm = New Bitmap(32,32) bm = New Bitmap(32,32) Does bm need only to be disposed at the end, or should it be disposed before each re-creation?

    Read the article

  • How is it possible to get the forms mouseposition when clicking inside a control?

    - by ikky
    Hi. I have a panel and have added a PictureBox to it. I have added mouse_click listeners to both the panel and the picturebox. When they are clicked i create a messagebox which tells me the mouse position. Problem: When i click the panel, i get the mouse position i want. When i click the pictureBox, i get the current position in that picturebox. What i want: I want both of the controls to get the current mouseposition on the form. I can also go with getting the current mouseposition of the panel, since it is overlaying the form. Does anybody know how i can do this? I've googled around for this, but can't seem to find anything about it. Thank you in advance.

    Read the article

  • Transparent control over WM Player ActiveX component in .NET

    - by FatDaemon
    I have a Windows media player activex component in my Form. On top of this WM player i have a picturebox with background color set to transparent. When i set an image for this picturebox , thought the image contains transparent areas it is displayed as black when the picturebox is above the WM player component. Where as if i place the PictureBox somewhere else in the form. The transparent area are rendered properly. So is there anyway that i can place a transparent image on top of a WM Player component. (hmm something like watermark may be). I want this picture to be displayed with may be 50% opacity when the video is playing in WM player control. Will GDI+ be of any use in this case?

    Read the article

< Previous Page | 1 2 3 4 5 6  | Next Page >