473,471 Members | 2,533 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Uploading picture on a form

6 New Member
Hello,

When i upload a picture onto my form my mouse starts lagging, everything starts lagging as a matter of fact. I think some settings have to be changed. What is happening to me right now is that i am moving a picture box around the screen and it lags when i move it with the uploading picture on the background. But when there is no picture on the background form there is no lag...! The picture box i am using is transparent is its suppose to show the form. Someone please help!

Thank you
May 14 '10 #1
5 3496
Curtis Rutland
3,256 Recognized Expert Specialist
When you say "uploading" do you mean you are in the active process of uploading a file, or do you mean it starts lagging after you have set a picture in the box?

You mentioned transparency...in my experience that can definitely increase your slow-down. Try turning the transparency off and testing again.
May 15 '10 #2
ThatThatGuy
449 Recognized Expert Contributor
@MarcosGalarza
What do you mean by "Lagging" ? did you meant flickering.....
May 15 '10 #3
MarcosGalarza
6 New Member
@ThatThatGuy
yes it flickers
May 17 '10 #4
ThatThatGuy
449 Recognized Expert Contributor
@MarcosGalarza
Im not understanding what did you say in your first post...

But let me get it... you are moving a picture via the mouse on a transparent form... or vice-versa... if its something like that then...

set the DoubleBuffered property of he form to true.... this will reduce flickering to much extent
May 18 '10 #5
medicinesoup
5 New Member
Ok this is what I am understanding:
you have a form with a large background picture (form.backgroundimage) and you have a picture box on top of that with a smaller picture loaded (picturebox.image)

your goal is to move the picturebox around the form when the user moves the mouse, like an oversized specialized mouse cursor, correct? So you are using an image and picturebox with transparency because you don't want the user to see the borders of the picturebox, just the image floating around the background scene, right?

let me know. Is that what you are trying to do?
If so, that method is pretty processor intense, and it may be pretty difficult to get rid of the flickering. However, I think I have an alternative that accomplishes the same goal with no fliker (or a little bit of flicker if your background image is larger than 8192 x 8192 pixles)

If not, then nevermind. I misunderstood.

P.S. What version of vb.net are you using?
Expand|Select|Wrap|Line Numbers
  1. Public Class Form1
  2.     Private f_bmpButterfly As Bitmap
  3.  
  4.     'THIS CODE ASSUMES YOU HAVE A FORM (NAMED Form1) CONTAINING A PICTUREBOX (NAMED PictureBox1)
  5.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  6.  
  7.         '   Load the background image
  8.         PictureBox1.BackgroundImage = New Bitmap("C:\your_background.jpg")
  9.         PictureBox1.Dock = DockStyle.Fill
  10.         PictureBox1.BackgroundImageLayout = ImageLayout.Stretch
  11.  
  12.         '   load the foreground image
  13.         f_bmpButterfly = New Bitmap("C:\your_foreground.png")
  14.  
  15.         'Do not load any image into the foreground (PictureBox1.Image) yet. 
  16.         'the MouseMove event will do that as soon as the user moves the cursor 
  17.         'over the picturebox
  18.     End Sub
  19.  
  20.     Private Sub PictureBox1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseMove
  21.         'get rid of the previous foreground image
  22.         If Not IsNothing(PictureBox1.Image) Then
  23.             PictureBox1.Image.Dispose()
  24.             PictureBox1.Image = Nothing
  25.         End If
  26.  
  27.         'Prepare a new, blank foreground image.
  28.         '   By making the foreground image as small as possible (no larger than the butterfly + it's position
  29.         '   the program doesn't have to think about any unneccessary areas of the image when displaying it.
  30.         Dim newBitmap As New Bitmap(e.X + f_bmpButterfly.Width, e.Y + f_bmpButterfly.Height, Imaging.PixelFormat.Format32bppArgb)
  31.  
  32.         'position the butterfly in the foreground
  33.         '   The graphics class is awesome! But don't forget to dispose of it when you're done.
  34.         Dim gr As Graphics
  35.  
  36.         '   Tell the grphics class which image you want to mess with.
  37.         gr = Graphics.FromImage(newBitmap)
  38.  
  39.         '   Paint the butterfly onto the blank foreground
  40.         gr.DrawImage(f_bmpButterfly, e.X, e.Y)
  41.  
  42.         'Display the new foreground image. no need to change the background image
  43.         PictureBox1.Image = newBitmap
  44.  
  45.         'Dispose ummanaged resources
  46.         gr.Dispose()
  47.         gr = Nothing
  48.     End Sub
  49. End Class
May 22 '10 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Salad | last post by:
Hi: I have a Bill of Lading template from the printer that I saved as a BMP. I created a new report and in the report's picture property told it the BMP file name. It brought the image in just...
2
by: nah | last post by:
Hello. I have a Visual Basic 6 program that calls a C++ DLL that I am in the process of writing. The DLL does some calculations and should draw some points in a Picture form contained in the...
2
by: yxq | last post by:
I want to build a picture form, how to do? Thank you
5
by: jason.tadeo | last post by:
I was wondering if anyone does any uploading picture scripts or how to do it where i could upload a picture and use php to change the picture size to what i want it to be. Anyone know where i could...
0
by: lyealain | last post by:
hi guys.. i have spent up my time looking and understanding the sample code from everywhere for uploading picture into mysql database by using asp script.. but i found it very hard to understand......
1
by: Gabe Matteson | last post by:
'GRAB CONTENTS OF UPLOADED FILEDim intFileLen as Integer Dim objStream as streamintfilelen = txtfileupload.PostedFile.ContentLength Dim arrFile(intFileLen) as ByteobjStream =...
44
by: badvoc | last post by:
Hi to all, Firstly I must state my knowledge of php is limited but I am a quick learner. I have taken on the task of finishing a friends website due to his untimely passing and have hit a problem...
2
by: melorie | last post by:
Warning: copy(../studentpic/Kim dae sik.JPG): failed to open stream: Permission denied in /hsphere/local/home/continen/continental.edu.ph/ver3/content/uploadpicture.php on line 27,i encountered this...
0
by: jesmee | last post by:
<%@ page import="java.util.List" %> <%@ page import="java.util.Iterator" %> <%@ page import="java.io.File" %> <%@ page import="org.apache.commons.fileupload.servlet.ServletFileUpload"%> ...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
0
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...
0
jinu1996
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...
1
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...
0
agi2029
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 project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
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 ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.