slewrate
2 New Member
Hello, I wrote this small function that reads an image file and copies parts of a that image into picture boxes which are added to a panel. This function works the way I wanted it to work for MOST pictures, however, for some large images, it doesn't. Sometimes the image inside the picture boxes is displayed like half the size it should be.
I wonder if someone could tell me why that is.
Thanks in advance
This is what I have:
Expand|Select|Wrap|Line Numbers
- voidreadpic()
- {
- openFileDialog1.ShowDialog();
- Imageimg=Image.FromFile(openFileDialog1.FileName.ToString());
- Bitmapbmp=(Bitmap)img;
- PictureBox[]px;
- intcounter=0;
- px=newPictureBox[(img.Size.Width/64)];
- for(intp=0;p<(img.Size.Height/64);p++)
- for(inti=0;i<(img.Size.Width/64);i++)
- {
- {
- Bitmapbmp2=newBitmap(64,64);
- Rectanglerect=newRectangle();
- rect.Height=64;
- rect.Width=64;
- rect.X=0+i*64;
- rect.Y=0+p*64;
- bmp2=CopyBitmap(bmp,rect);
- px[i]=newPictureBox();
- px[i].Name=counter.ToString();
- px[i].Tag=px[i].Name;
- px[i].BorderStyle=BorderStyle.Fixed3D;
- px[i].Height=64;
- px[i].Width=64;
- px[i].Image=bmp2;
- px[i].Left=i*64;
- px[i].Location=newPoint(1+i*64,1+p*64);
- px[i].Click+=newEventHandler(Form1_Click);
- panel1.Controls.Add(px[i]);
- counter++;
- }
- }
- }
Jun 13 '08 #1
Subscribe Reply
3 964
Plater 7,872 Recognized Expert Expert
Why don't you just use the .GetThumbnail() function to do the resizing for you?
Or is that contained with your CopyBitmap function?
Jun 16 '08 #2
reply
tlhintoq 3,525 Recognized Expert Specialist
Does this run just they way you entered it here?
I have my doubts about lines 12-15...
12. for loop declaration
13. for loop declaration
14. {
15. {
Shouldn't this be...
12. for loop
13. {
14. for loop
15. {
I'm just wondering if the way posted works, is legal and does something different or interesting from the 'normal' or 'other' way to do nested loops that I suggested.
Jun 17 '08 #3
reply
slewrate 2 New Member
I changed the position of the braces but it doesn't have an effect.
Jun 17 '08 #4
reply
Sign in to post your reply or Sign up for a free account.
Similar topics
7 8096 handling mousedown for dynamic pictureboxes by: Scott Mackay |last post by: Hi, I'm using visual studio dotnet 2002 programming in vb can anyone tell me how I can handle the mousedown event for pictureboxes I create dynamically at runtime? I've tried setting the mousedown to handle mybase.mousedown but it doesn't detect the mousedown event until I move out of the pictureboxes I have created (only works on the... Visual Basic .NET |
5 2264 Context Menu for PictureBoxes by: lgbjr |last post by: Hello All, I have several Pictureboxes (linked to an AccessDB) on a VB.NET form. I would like to use a context menu to allow the user to open the picture in their default picture viewer or editor. I'd like to use the same default viewer/editor and open with... choices that are present on the users computer. Does anyone know how I can... Visual Basic .NET |
1 3178 rotate or resize pictureboxes, labels, textboxes at runtime by: Rohan |last post by: Hi There, Is it possible to rotate or resize pictureboxes, labels, textboxes at runtime? And I even wanted to make textbox and label controls Transperent ? Visual Basic .NET |
4 1404 Learning - displaying selection in pictureboxes by: KitKat |last post by: Problem trying to figure this out, using a combo box selection I need to go to each folder, Cam 1, Cam 2, Cam 4, Cam 6, Cam 7,and Cam 8 and display each picture (from selection) from each folder and display in pictureboxes pcbCam1, pcbCam2, pcbCam4, pcbCam6, pcbCam7, and pcbCam8. So far the code works for one picture box not the others. Also... Visual Basic .NET |
2 3633 transparent labels on pictureboxes by: Pascal |last post by: Je veux que mes label soit transparent aussi sur mes picturebox alors j'écris : i want my labels to be transparent on my pictureboxes so i wrote : Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Label1.Parent = PictureBox1 Label1.BackColor = Color.Transparent Label2.Parent = PictureBox2... Visual Basic .NET |
4 1847 creating pictureboxes on the fly by: John Devlon |last post by: Hi, I'm trying to fill a form in visual basic .net with pictureboxes Unfortunately, it doesn't work... the boxes don't show Can anyone please help me ? Dim x As Integer = 0 Dim myCollection As List(Of PictureBox) = New List(Of PictureBox) Visual Basic .NET |
925 Using Pictureboxes on top of Pictureboxes??? Should be simple by: Blarneystone |last post by: I am pulling my hair out over this one. I've got a picturebox with just a simple gradient as the background for my interface. It is in 16bit RGB color. I've created some pictures I'll use as buttons that I put in pictureboxes on top of the main picturebox. In other words, if the color behind my button is 247,247,247 I would want my custom... Visual Basic .NET |
1868 flickering when scrolling panel with mutiple pictureboxes by: mike |last post by: Hi guys, I have a windows form and on load event I dynamically created a panel and dynamically create/add pictureboxes to panel and added a panel to the form with docking with fill. I am basically creating a thumb nails view for multiple pictures. Two question. 1I have set the panel's autoscroll to true, so I can actually see and scroll... Visual Basic .NET |
2 1033 Create pictureboxes on the fly by: djpaul |last post by: Heey! For my program i need to create pictureboxes on the fly. After adding pictures to the database with a surten folder you can eddit the pictures or the text that's with it. But when i select a folder in the program then he needs to create pictureboxes to show a thumbnail of them so you can see wich photo it is. (like acdsee does...:) ) ... .NET Framework |
7295
What is ONU? by: marktang |last post by: ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main... General |
7197 Changing the language in Windows 10 by: Hystou |last post by: Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language... Windows Server |
7598
Maximizing Business Potential: The Nexus of Website Design and Digital Marketing by: jinu1996 |last post by: In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that... Online Marketing |
1 7157 The easy way to turn off automatic updates for Windows 10/11 by: Hystou |last post by: Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For... Windows Server |
5737
AI Job Threat for Devs by: agi2029 |last post by: Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then... Career Advice |
1 5120
Access Europe - Using VBA to create a class based on a table - Wed 1 May by: isladogs |last post by: The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes... Microsoft Access / VBA |
1641 transfer the data from one system to another through ip address by: 6302768590 |last post by: Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system C# / C Sharp |
1 833
How to add payments to a PHP MySQL app. by: muto222 |last post by: How can i add a mobile payment intergratation into php mysql website. PHP |
504
Comprehensive Guide to Website Development in Toronto: Expert Insights from BSMN Consultancy by: bsmnconsultancy |last post by: In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating... General |