Search Results

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

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

  • Multiple PictureBoxs' C#

    - by Austin Smith
    I'm having a hard time figuring this out. I know pictureBox only lets you display one image a time. I'm trying to create a pictureBox for each image in my collection. For instance if I have ten images in my List, then the method should create ten pictureBox for those respective images so each one is displayes in a pictureBox. I'm not sure which would be better a for loop or a foreach loop instead. every time the loop increments both the varaiables XCoordinate and YCoordinate which are the location of the PictireBox shoulld increase so that the PictureBox won't overlap one another in the Form. The reason for the method is that the number of images in the collection can change everytime the application will run. That's why I'm not creating them manually. So after its done all the pictures in the list should appear in a picture.Box. The box should be all the same size the only difference is the location on the form and the images inside them. Please any help and I will be grateful

    Read the article

  • creating grafhic and save it as Bitmap

    - by Hesam Qodsi
    I have to questions : 1) I have a PictureBox and its Dock is Fill , when i resize the Form then i cannot creat Grafhic on the part of the PictureBox that is extended whta is the problem? 2) I want to convert the Grafhic that is created on a PictureBox to Bitmap and save it as *.JPG or *.bmp how can i do this?

    Read the article

  • C# Drawing On Separate Thread [migrated]

    - by Zaid
    I have a "public static" class called "DrawTest" and inside is a method public static DrawRandomRectangle(Bitmap g) { } I want to call that method and draw bunches of stuff and then update the pictureBox that uses the image on a separate thread. To simplify, I'm not trying to make anything specific I'm just trying to learn how to draw and update an image inside of a picturebox on a separate thread.

    Read the article

  • Semi-transparent PNG Image on transparent Form

    - by Marco Bruggmann
    Hello, I have a problem dealing with transparent images on transparent Forms. I have been trying and looking for a solution but nothing useful came up. The problem is: I have a Form, this Form has a Panel and the Panel has a PictureBox. Form and Panel are transparent. Now, if the image of the PictureBox has no semi-transparent it works. But if there is a gradient transparency then the "transparent color" is shown. I need the Panel and the PictureBox, so the PerPixelAlpha does not apply for this case. The Form will also have more Controls that should be visible and non transparent (just the PNG image should be transparent). The image below shows: [Left] When the Panel is not transparent. [Center] When the Panel is transparent. [Right] Desired effect (done with PerPixelAlpha). http://www.freeimagehosting.net/uploads/3937fe974d.jpg THX Marco

    Read the article

  • [C#] GrayScale (by ColorMatrix) causes OutOfMemoryException. Why ?

    - by Tony
    I have 2 forms, A and B. On the Form A, I click a button and an Image is being loaded to a PictureBox located ona the Form B. And, I want to set GrayScale to this image by: public void SetGrayScale(PictureBox pb) { ColorMatrix matrix = new ColorMatrix(new float[][] { new float[] {0.299f, 0.299f, 0.299f, 0, 0}, new float[] {0.587f, 0.587f, 0.587f, 0, 0}, new float[] {0.114f, 0.114f, 0.114f, 0, 0}, new float[] { 0, 0, 0, 1, 0}, new float[] { 0, 0, 0, 0, 0} }); Image image = (Bitmap)pb.Image.Clone(); ImageAttributes attributes = new ImageAttributes(); attributes.SetColorMatrix(matrix); Graphics graphics = Graphics.FromImage(image); graphics.DrawImage(image, new Rectangle(0, 0, image.Width, image.Height), 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, attributes); graphics.Dispose(); pb.Image = image; } This code works properly when the PictureBox is on the same form (A). But, when it is on the Form B, the OutOfMemoryException is raised. Why ?

    Read the article

  • Embedding .net remoting program in WEB

    - by flufferok
    So, here is a deal. I have client-server application(dotNet remoting). Client side has few trackbars, checkboxes, buttons and picturebox. Server is a console application and does only calculation from client. Client's picturebox make some visualisation of calculation in picturebox. All calulations and relative classes are in dll file. Now I have to embed client application in web site. All kind of technologies are accepted, but I want to minimize forces applied to embedding. So, what is the best way to do embedding?

    Read the article

  • Drawing a continuous rectangle

    - by JAYMIN
    Hi..i m currently working on visual c++ 2008 express edition.. in my project i have a picturebox which contains an image, now i have to draw a rectangle to enaable the user to select a part of the image.. I have used the "MouseDown" event of the picturebox and the below code to draw a rectangle: Void pictureBox1_MouseDown(System::Object^ sender, Windows::Forms::MouseEventArgs^ e) { Graphics^ g = pictureBox1-CreateGraphics(); Pen^ pen = gcnew Pen(Color::Blue); g-DrawRectangle( pen , e-X ,e-Y,width,ht); } now in the "DrawRectangle" the arguments "width" and "ht" are static, so the above code results in the drawing of a rectangle at the point where the user presses the mouse button on the image in picturebox... i want to allow the user to be able to drag the cursor and draw a rectangle of size that he wishes to.. Plz help me on this.. Thanx..

    Read the article

  • Update image in ASP.NET page from memory without refreshing the page.

    - by ZeeMan
    I have a command line C# server and an ASP.NET client, they both communicate via .NET Remoting. The server is sending the client still images grabbed from a webcam at say 2 frames a second. I can pass the images down to the client via a remote method call and the image ends up in this client method: public void Update(System.Drawing.Image currentFrame) { // I need to display the currentFrame on my page. } How do i display the image on the a page without saving the image to the hard disc? If it was a winForms app i could pass currentFrame to a picturebox ie. picturebox.Image = currentFrame. The above Update method gets fired at least 2 times a second. If the client was a winForms app i could simply put picturebox.Image = currentFrame and the current frame on the screen would automatically get updated. How do i achieve the same effect with ASP.NET? Will the whole page need to be reloaded etc?

    Read the article

  • Window screenshot using WinAPI

    - by Evl-ntnt
    How to make a screenshot of program window using WinAPI & C#? I sending WM_PAINT (0x000F) message to window, which I want to screenshot, wParam = HDChandle, but no screenshot in my picturebox. If I send a WM_CLOSE message, all waorking (target window closes). What I do wrong with WM_PAINT? May be HDC is not PictureBox (WinForms) component? P.S. GetLastError() == "" [DllImport("User32.dll")] public static extern Int64 SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam); ..... SendMessage(targetWindowHandle, 0x000F, pictureBox.Handle, IntPtr.Zero);

    Read the article

  • How to edit item in a listbox shown from reading a .csv file?

    - by Shuvo
    I am working in a project where my application can open a .csv file and read data from it. The .csv file contains the latitude, longitude of places. The application reads data from the file shows it in a static map and display icon on the right places. The application can open multiple file at a time and it opens with a new tab every time. But I am having trouble in couple of cases When I am trying to add a new point to the .csv file opened. I am able to write new point on the same file instead adding a new point data to the existing its replacing others and writing the new point only. I cannot use selectedIndexChange event to perform edit option on the listbox and then save the file. Any direction would be great. using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.IO; namespace CourseworkExample { public partial class Form1 : Form { public GPSDataPoint gpsdp; List<GPSDataPoint> data; List<PictureBox> pictures; List<TabPage> tabs; public static int pn = 0; private TabPage currentComponent; private Bitmap bmp1; string[] symbols = { "hospital", "university" }; Image[] symbolImages; ListBox lb = new ListBox(); string name = ""; string path = ""; public Form1() { InitializeComponent(); data = new List<GPSDataPoint>(); pictures = new List<PictureBox>(); tabs = new List<TabPage>(); symbolImages = new Image[symbols.Length]; for (int i = 0; i < 2; i++) { string location = "data/" + symbols[i] + ".png"; symbolImages[i] = Image.FromFile(location); } } private void openToolStripMenuItem_Click(object sender, EventArgs e) { FileDialog ofd = new OpenFileDialog(); string filter = "CSV File (*.csv)|*.csv"; ofd.Filter = filter; DialogResult dr = ofd.ShowDialog(); if (dr.Equals(DialogResult.OK)) { int i = ofd.FileName.LastIndexOf("\\"); name = ofd.FileName; path = ofd.FileName; if (i > 0) { name = ofd.FileName.Substring(i + 1); path = ofd.FileName.Substring(0, i + 1); } TextReader input = new StreamReader(ofd.FileName); string mapName = input.ReadLine(); GPSDataPoint gpsD = new GPSDataPoint(); gpsD.setBounds(input.ReadLine()); string s; while ((s = input.ReadLine()) != null) { gpsD.addWaypoint(s); } input.Close(); TabPage tabPage = new TabPage(); tabPage.Location = new System.Drawing.Point(4, 22); tabPage.Name = "tabPage" + pn; lb.Width = 300; int selectedindex = lb.SelectedIndex; lb.Items.Add(mapName); lb.Items.Add("Bounds"); lb.Items.Add(gpsD.Bounds[0] + " " + gpsD.Bounds[1] + " " + gpsD.Bounds[2] + " " + gpsD.Bounds[3]); lb.Items.Add("Waypoint"); foreach (WayPoint wp in gpsD.DataList) { lb.Items.Add(wp.Name + " " + wp.Latitude + " " + wp.Longitude + " " + wp.Ele + " " + wp.Sym); } tabPage.Controls.Add(lb); pn++; tabPage.Padding = new System.Windows.Forms.Padding(3); tabPage.Size = new System.Drawing.Size(192, 74); tabPage.TabIndex = 0; tabPage.Text = name; tabPage.UseVisualStyleBackColor = true; tabs.Add(tabPage); tabControl1.Controls.Add(tabPage); tabPage = new TabPage(); tabPage.Location = new System.Drawing.Point(4, 22); tabPage.Name = "tabPage" + pn; pn++; tabPage.Padding = new System.Windows.Forms.Padding(3); tabPage.Size = new System.Drawing.Size(192, 74); tabPage.TabIndex = 0; tabPage.Text = mapName; string location = path + mapName; tabPage.UseVisualStyleBackColor = true; tabs.Add(tabPage); PictureBox pb = new PictureBox(); pb.Name = "pictureBox" + pn; pb.Image = Image.FromFile(location); tabControl2.Controls.Add(tabPage); pb.Width = pb.Image.Width; pb.Height = pb.Image.Height; tabPage.Controls.Add(pb); currentComponent = tabPage; tabPage.Width = pb.Width; tabPage.Height = pb.Height; pn++; tabControl2.Width = pb.Width; tabControl2.Height = pb.Height; bmp1 = (Bitmap)pb.Image; int lx, ly; float realWidth = gpsD.Bounds[1] - gpsD.Bounds[3]; float imageW = pb.Image.Width; float dx = imageW * (gpsD.Bounds[1] - gpsD.getWayPoint(0).Longitude) / realWidth; float realHeight = gpsD.Bounds[0] - gpsD.Bounds[2]; float imageH = pb.Image.Height; float dy = imageH * (gpsD.Bounds[0] - gpsD.getWayPoint(0).Latitude) / realHeight; lx = (int)dx; ly = (int)dy; using (Graphics g = Graphics.FromImage(bmp1)) { Rectangle rect = new Rectangle(lx, ly, 20, 20); if (gpsD.getWayPoint(0).Sym.Equals("")) { g.DrawRectangle(new Pen(Color.Red), rect); } else { if (gpsD.getWayPoint(0).Sym.Equals("hospital")) { g.DrawImage(symbolImages[0], rect); } else { if (gpsD.getWayPoint(0).Sym.Equals("university")) { g.DrawImage(symbolImages[1], rect); } } } } pb.Image = bmp1; pb.Invalidate(); } } private void openToolStripMenuItem_Click_1(object sender, EventArgs e) { FileDialog ofd = new OpenFileDialog(); string filter = "CSV File (*.csv)|*.csv"; ofd.Filter = filter; DialogResult dr = ofd.ShowDialog(); if (dr.Equals(DialogResult.OK)) { int i = ofd.FileName.LastIndexOf("\\"); name = ofd.FileName; path = ofd.FileName; if (i > 0) { name = ofd.FileName.Substring(i + 1); path = ofd.FileName.Substring(0, i + 1); } TextReader input = new StreamReader(ofd.FileName); string mapName = input.ReadLine(); GPSDataPoint gpsD = new GPSDataPoint(); gpsD.setBounds(input.ReadLine()); string s; while ((s = input.ReadLine()) != null) { gpsD.addWaypoint(s); } input.Close(); TabPage tabPage = new TabPage(); tabPage.Location = new System.Drawing.Point(4, 22); tabPage.Name = "tabPage" + pn; ListBox lb = new ListBox(); lb.Width = 300; lb.Items.Add(mapName); lb.Items.Add("Bounds"); lb.Items.Add(gpsD.Bounds[0] + " " + gpsD.Bounds[1] + " " + gpsD.Bounds[2] + " " + gpsD.Bounds[3]); lb.Items.Add("Waypoint"); foreach (WayPoint wp in gpsD.DataList) { lb.Items.Add(wp.Name + " " + wp.Latitude + " " + wp.Longitude + " " + wp.Ele + " " + wp.Sym); } tabPage.Controls.Add(lb); pn++; tabPage.Padding = new System.Windows.Forms.Padding(3); tabPage.Size = new System.Drawing.Size(192, 74); tabPage.TabIndex = 0; tabPage.Text = name; tabPage.UseVisualStyleBackColor = true; tabs.Add(tabPage); tabControl1.Controls.Add(tabPage); tabPage = new TabPage(); tabPage.Location = new System.Drawing.Point(4, 22); tabPage.Name = "tabPage" + pn; pn++; tabPage.Padding = new System.Windows.Forms.Padding(3); tabPage.Size = new System.Drawing.Size(192, 74); tabPage.TabIndex = 0; tabPage.Text = mapName; string location = path + mapName; tabPage.UseVisualStyleBackColor = true; tabs.Add(tabPage); PictureBox pb = new PictureBox(); pb.Name = "pictureBox" + pn; pb.Image = Image.FromFile(location); tabControl2.Controls.Add(tabPage); pb.Width = pb.Image.Width; pb.Height = pb.Image.Height; tabPage.Controls.Add(pb); currentComponent = tabPage; tabPage.Width = pb.Width; tabPage.Height = pb.Height; pn++; tabControl2.Width = pb.Width; tabControl2.Height = pb.Height; bmp1 = (Bitmap)pb.Image; int lx, ly; float realWidth = gpsD.Bounds[1] - gpsD.Bounds[3]; float imageW = pb.Image.Width; float dx = imageW * (gpsD.Bounds[1] - gpsD.getWayPoint(0).Longitude) / realWidth; float realHeight = gpsD.Bounds[0] - gpsD.Bounds[2]; float imageH = pb.Image.Height; float dy = imageH * (gpsD.Bounds[0] - gpsD.getWayPoint(0).Latitude) / realHeight; lx = (int)dx; ly = (int)dy; using (Graphics g = Graphics.FromImage(bmp1)) { Rectangle rect = new Rectangle(lx, ly, 20, 20); if (gpsD.getWayPoint(0).Sym.Equals("")) { g.DrawRectangle(new Pen(Color.Red), rect); } else { if (gpsD.getWayPoint(0).Sym.Equals("hospital")) { g.DrawImage(symbolImages[0], rect); } else { if (gpsD.getWayPoint(0).Sym.Equals("university")) { g.DrawImage(symbolImages[1], rect); } } } } pb.Image = bmp1; pb.Invalidate(); MessageBox.Show(data.ToString()); } } private void exitToolStripMenuItem_Click(object sender, EventArgs e) { this.Close(); } private void addBtn_Click(object sender, EventArgs e) { string wayName = nameTxtBox.Text; float wayLat = Convert.ToSingle(latTxtBox.Text); float wayLong = Convert.ToSingle(longTxtBox.Text); float wayEle = Convert.ToSingle(elevTxtBox.Text); WayPoint wp = new WayPoint(wayName, wayLat, wayLong, wayEle); GPSDataPoint gdp = new GPSDataPoint(); data = new List<GPSDataPoint>(); gdp.Add(wp); lb.Items.Add(wp.Name + " " + wp.Latitude + " " + wp.Longitude + " " + wp.Ele + " " + wp.Sym); lb.Refresh(); StreamWriter sr = new StreamWriter(name); sr.Write(lb); sr.Close(); DialogResult result = MessageBox.Show("Save in New File?","Save", MessageBoxButtons.YesNo); if (result == DialogResult.Yes) { SaveFileDialog saveDialog = new SaveFileDialog(); saveDialog.FileName = "default.csv"; DialogResult saveResult = saveDialog.ShowDialog(); if (saveResult == DialogResult.OK) { sr = new StreamWriter(saveDialog.FileName, true); sr.WriteLine(wayName + "," + wayLat + "," + wayLong + "," + wayEle); sr.Close(); } } else { // sr = new StreamWriter(name, true); // sr.WriteLine(wayName + "," + wayLat + "," + wayLong + "," + wayEle); sr.Close(); } MessageBox.Show(name + path); } } } GPSDataPoint.cs using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; namespace CourseworkExample { public class GPSDataPoint { private float[] bounds; private List<WayPoint> dataList; public GPSDataPoint() { dataList = new List<WayPoint>(); } internal void setBounds(string p) { string[] b = p.Split(','); bounds = new float[b.Length]; for (int i = 0; i < b.Length; i++) { bounds[i] = Convert.ToSingle(b[i]); } } public float[] Bounds { get { return bounds; } } internal void addWaypoint(string s) { WayPoint wp = new WayPoint(s); dataList.Add(wp); } public WayPoint getWayPoint(int i) { if (i < dataList.Count) { return dataList[i]; } else return null; } public List<WayPoint> DataList { get { return dataList; } } internal void Add(WayPoint wp) { dataList.Add(wp); } } } WayPoint.cs using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace CourseworkExample { public class WayPoint { private string name; private float ele; private float latitude; private float longitude; private string sym; public WayPoint(string name, float latitude, float longitude, float elevation) { this.name = name; this.latitude = latitude; this.longitude = longitude; this.ele = elevation; } public WayPoint() { name = "no name"; ele = 3.5F; latitude = 3.5F; longitude = 0.0F; sym = "no symbol"; } public WayPoint(string s) { string[] bits = s.Split(','); name = bits[0]; longitude = Convert.ToSingle(bits[2]); latitude = Convert.ToSingle(bits[1]); if (bits.Length > 4) sym = bits[4]; else sym = ""; try { ele = Convert.ToSingle(bits[3]); } catch (Exception e) { ele = 0.0f; } } public float Longitude { get { return longitude; } set { longitude = value; } } public float Latitude { get { return latitude; } set { latitude = value; } } public float Ele { get { return ele; } set { ele = value; } } public string Name { get { return name; } set { name = value; } } public string Sym { get { return sym; } set { sym = value; } } } } .csv file data birthplace.png 51.483788,-0.351906,51.460745,-0.302982 Born Here,51.473805,-0.32532,-,hospital Danced here,51,483805,-0.32532,-,hospital

    Read the article

  • c# multi - point selection on an image

    - by sinem
    I'm designing interface with visual c# for my image processing project. i'm not good at c# codding. and i haven't enough time. I need point selection on an image and classification these points for using in my image processing code at vhdl. Orginal image will stay at a picturebox and i will use selected image in another picturebox. How i can select points on an image ? please could you help me or send me similar code? I'm getting so confused thank you.

    Read the article

  • How do I make a form transparent while keeping the controls fully visible?

    - by Power-Mosfet
    I would like to have a form in which the controls on the form are fully visible but the form itself is invisible. If I change the form's Opacity, this makes both the form and the controls on it semi-transparent, so this doesn't work. I can't do this by setting the form's TransparencyKey, since I have a PictureBox on the form. If the image in the PictureBox happens to contain pixels that match the TransparencyKey, they appear as openings in the form, which I don't want.

    Read the article

  • calling contextmenustrip programmatically c#

    - by jello
    I programmatically create a Picture Box in c# windows program. I assign it with a value for the Tag property. I would like to print out that tag number programmatically, just for test purposes. so I try this: private void Form1_Load(object sender, EventArgs e) { pic.ContextMenuStrip = contextMenuStrip1; pic.ContextMenuStrip.Click += new EventHandler(this.MyPicHandler); } void MyPicHandler(object sender, EventArgs e) { PictureBox pic = sender as PictureBox; MessageBox.Show(pic.Tag.ToString()); } But when I right-click on the picture, and click on the menu item, it gives me an exception. "A NullReferenceException was unhandled" "Object reference not set to an instance of an object.". anyone's got an idea what's going on?

    Read the article

  • calling WinForms contextmenustrip programmatically

    - by jello
    I programmatically create a Picture Box in c# windows program. I assign it with a value for the Tag property. I would like to print out that tag number programmatically, just for test purposes. so I try this: private void Form1_Load(object sender, EventArgs e) { pic.ContextMenuStrip = contextMenuStrip1; pic.ContextMenuStrip.Click += new EventHandler(this.MyPicHandler); } void MyPicHandler(object sender, EventArgs e) { PictureBox pic = sender as PictureBox; MessageBox.Show(pic.Tag.ToString()); } But when I right-click on the picture, and click on the menu item, it gives me an exception. "A NullReferenceException was unhandled" "Object reference not set to an instance of an object.". anyone's got an idea what's going on?

    Read the article

  • C# WinForms problem with draw image

    - by Paul
    Hi I have this class: class OriginalImage: Form { private Image image; private PictureBox pb; public OriginalImage() { pb = new PictureBox {SizeMode = PictureBoxSizeMode.CenterImage}; pb.SizeMode = PictureBoxSizeMode.StretchImage; Controls.Add(pb); image = Image.FromFile(@"Image/original.jpg"); this.Width = image.Width; this.Height = image.Height; this.Text = "Original image"; this.Paint += new PaintEventHandler(Drawer); } public virtual void Drawer(object source, PaintEventArgs e) { Graphics g = pb.CreateGraphics(); g.DrawImage(image,0,0); } I call this create object OriginalImage in other form on button click, but image is not draw? Where is problem? public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { var oi = new OriginalImage(); oi.Show(); } }

    Read the article

  • C#: Windows Forms: What could cause Invalidate() to not redraw?

    - by Rosarch
    I'm using Windows Forms. For a long time, pictureBox.Invalidate(); worked to make the screen be redrawn. However, it now doesn't work and I'm not sure why. this.worldBox = new System.Windows.Forms.PictureBox(); this.worldBox.BackColor = System.Drawing.SystemColors.Control; this.worldBox.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.worldBox.Location = new System.Drawing.Point(170, 82); this.worldBox.Name = "worldBox"; this.worldBox.Size = new System.Drawing.Size(261, 250); this.worldBox.TabIndex = 0; this.worldBox.TabStop = false; this.worldBox.MouseMove += new System.Windows.Forms.MouseEventHandler(this.worldBox_MouseMove); this.worldBox.MouseDown += new System.Windows.Forms.MouseEventHandler(this.worldBox_MouseDown); this.worldBox.MouseUp += new System.Windows.Forms.MouseEventHandler(this.worldBox_MouseUp); Called in my code to draw the world appropriately: view.DrawWorldBox(worldBox, canvas, gameEngine.GameObjectManager.Controllers, selectedGameObjects, LevelEditorUtils.PREVIEWS); View.DrawWorldBox: public void DrawWorldBox(PictureBox worldBox, Panel canvas, ICollection<IGameObjectController> controllers, ICollection<IGameObjectController> selectedGameObjects, IDictionary<string, Image> previews) { int left = Math.Abs(worldBox.Location.X); int top = Math.Abs(worldBox.Location.Y); Rectangle screenRect = new Rectangle(left, top, canvas.Width, canvas.Height); IDictionary<float, ICollection<IGameObjectController>> layers = LevelEditorUtils.LayersOfControllers(controllers); IOrderedEnumerable<KeyValuePair<float, ICollection<IGameObjectController>>> sortedLayers = from item in layers orderby item.Key descending select item; using (Graphics g = Graphics.FromImage(worldBox.Image)) { foreach (KeyValuePair<float, ICollection<IGameObjectController>> kv in sortedLayers) { foreach (IGameObjectController controller in kv.Value) { // ... float scale = controller.View.Scale; float width = controller.View.Width; float height = controller.View.Height; Rectangle controllerRect = new Rectangle((int)controller.Model.Position.X, (int)controller.Model.Position.Y, (int)(width * scale), (int)(height * scale)); // cull objects that aren't intersecting with the canvas if (controllerRect.IntersectsWith(screenRect)) { Image img = previews[controller.Model.HumanReadableName]; g.DrawImage(img, controllerRect); } if (selectedGameObjects.Contains(controller)) { selectionRectangles.Add(controllerRect); } } } foreach (Rectangle rect in selectionRectangles) { g.DrawRectangle(drawingPen, rect); } selectionRectangles.Clear(); } worldBox.Invalidate(); } What could I be doing wrong here?

    Read the article

  • (C#) graphics.drawImage has a size limit? How to deal with it?

    - by DGH
    I am attempting to display a very large graphical representation of some data. I am using a bitmap for persistent storage of the image and e.Graphics.DrawImage(myBitmap, new Point(0,0)) in the onPaint of a PictureBox control on my form. I have noticed (and heard mentioned on other sites) that if my image has a height or width greater than 2^15, I get a Parameter not Valid exception, but I have not found any official documentation of this limit. Is this 2^15 image size limit a definite, official part of Graphics.DrawImage? Are there any simple workarounds to render my entire image onto the form? (Yes, the pictureBox is set to the same size as the image, or bigger. Side question though, should I just be using the onPaint of the form itself instead of a picture box?)

    Read the article

  • Building and rendering a bitmap from a double array

    - by Ami
    I'm new to c# and I'm sure I'm missing something simple here. I'm trying to build a bitmap from integer values (0-255) in a double array and then render it in a PictureBox. I think my Bitmap is getting generated but it isn't displaying in my PictureBox. Bitmap bmp = new Bitmap(image_width, image_height); Color pxl_color = new Color(); for (int i = 0; i < image_width; i++) { for (int j = 0; j < image_height; j++) { pxl_color = Color.FromArgb(array_bitmap[i][j]); bmp.SetPixel(i, j, pxl_color); } } PictureBox1.Image = bmp; Thanks in advance.

    Read the article

  • HOW TO GET WEB CAM IMAGES IN C#

    - by SR Dusad
    Hi I m working on online video conferencing project in c# and .Net4.0 I want a library or code which i can used for collecting web camera inges per second in diferent form. I try this by using the AVICAP32, in which we send Messages for diferent purpose like copy or edit frames.but in this we have to pass a reference of picturebox while creating handler as given below mCapHwnd = capCreateCaptureWindowA("0", 268435456 | 1073741824, 0, 0, 640, 480,picturebox1.Handle.ToInt32(), 0); usiing these commands i m able to capture images but the problem comes when i minimize the picturebox form . at that time doesn't create new image . I think this is happened because i minimize the form and when it copy the image from this clipboard it doesn't shhow anything. How can i solve this problem . Any type of help will be appreciated. Thanks srdusad

    Read the article

  • Function to register functions to be called if event invoked.

    - by zaidwaqi
    Hi, I have a Panel which contains 20 PictureBox controls. If a user clicks on any of the controls, I want a method within the Panel to be called. How do I do this? public class MyPanel : Panel { public MyPanel() { for(int i = 0; i < 20; i++) { Controls.Add(new PictureBox()); } } // DOESN'T WORK. // function to register functions to be called if the pictureboxes are clicked. public void RegisterFunction( <function pointer> func ) { foreach ( Control c in Controls ) { c.Click += new EventHandler( func ); } } } How do I implement RegisterFunction()? Also, if there are cool C# features that can make the code more elegant, please share. Thanks.

    Read the article

  • Method to register method to be called when event is raised

    - by zaidwaqi
    I have a Panel which contains 20 PictureBox controls. If a user clicks on any of the controls, I want a method within the Panel to be called. How do I do this? public class MyPanel : Panel { public MyPanel() { for(int i = 0; i < 20; i++) { Controls.Add(new PictureBox()); } } // DOESN'T WORK. // function to register functions to be called if the pictureboxes are clicked. public void RegisterFunction( <function pointer> func ) { foreach ( Control c in Controls ) { c.Click += new EventHandler( func ); } } } How do I implement RegisterFunction()? Also, if there are cool C# features that can make the code more elegant, please share.

    Read the article

  • Change Image in Resources at Runtime

    - by zaidwaqi
    Hi, My understanding of Resources is that I can combine resources i.e. images and my program into single executable. Let's say I have image pic1.png and I put it into Resource of my project, and is accessible with Properties.Resource.pic1. For example, PictureBox pb = new PictureBox(); pb.Image = Properties.Resource.pic1; What I want to do is for that my program will be able to replace this image at runtime. For example, my program runs, and locate newPicture.png, and use this new image to replace pic1.png that was originally used. Maybe my question is better reworded as "Can I include new image into Resources at runtime?" Please help. Thanks.

    Read the article

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