473,508 Members | 2,454 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

resizing images

27 New Member
so i have a several arrayed image boxes and i want the user during run time to be able to resize it.. would anyone know how?

THANK YOU!!!
Aug 5 '07 #1
7 1326
Killer42
8,435 Recognized Expert Expert
so i have a several arrayed image boxes and i want the user during run time to be able to resize it.. would anyone know how?
I guess you need to decide what sort of interface you have in mind to allow the user to resize an image.

If I remember correctly, you're using VB6?
Aug 6 '07 #2
Killer42
8,435 Recognized Expert Expert
Under the assumption that you are using VB6, here's a little sample I just banged together. I'm a bit surprised it worked as well as it did. Just create a new project with a form, add a picture box, and paste this into the code window for the form (replacing whatever is already there).
Expand|Select|Wrap|Line Numbers
  1. Option Explicit
  2. DefLng A-Z
  3.  
  4. Private MouseDown_X As Single, MouseDown_Y As Single
  5. Private MouseDown_Width As Single, MouseDown_Height As Single
  6.  
  7.  
  8. Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
  9.   MouseDown_X = X
  10.   MouseDown_Y = Y
  11.   MouseDown_Width = Picture1.Width
  12.   MouseDown_Height = Picture1.Height
  13. End Sub
  14.  
  15. Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  16.   Static Busy As Boolean
  17.   If Not Busy Then
  18.     Busy = True
  19.     If Button And vbLeftButton Then
  20.       ResizePicture X, Y
  21.     End If
  22.     Busy = False
  23.   End If
  24. End Sub
  25.  
  26. Private Sub ResizePicture(X As Single, Y As Single)
  27.   Dim NewWidth As Single, NewHeight As Single
  28.   NewWidth = MouseDown_Width + (X - MouseDown_X)
  29.   NewHeight = MouseDown_Height + (Y - MouseDown_Y)
  30.   Picture1.Width = NewWidth
  31.   Picture1.Height = NewHeight
  32.   DoEvents
  33. End Sub
Aug 6 '07 #3
akynaya
27 New Member
Thank You I Will Try This Code =]
Aug 7 '07 #4
akynaya
27 New Member
IT does works but, if there are several images boxes and instead of a form you have a picture box as your work area? how can i resize it?
Aug 7 '07 #5
Killer42
8,435 Recognized Expert Expert
IT does works but, if there are several images boxes and instead of a form you have a picture box as your work area? how can i resize it?
The fact that they reside within a picturebox shouldn't really make any difference.

If there are a bunch of images, a couple of ideas come to mind for tracking them...
  • You could encode the "mousedown details" into the Tag property for each image, so that you don't have to store them somewhere else.
  • Perhaps the simplest thing is to make the images a control array, and create a form-level variable array to keep the info relating to them. For example...
    Expand|Select|Wrap|Line Numbers
    1. Private Type ImageStuff
    2.   X As Single
    3.   Y As Single
    4.   Width As Single
    5.   Height As Single
    6. End Type
    7. Private ImageDetails() As ImageStuff
    8. ' You will need to decide how many elements you want in the above array,
    9. ' based on the size of your control array.
    10. '
    11. ' ...
    12. '
    13. Private Sub Image1_MouseDown(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
    14.   With ImageDetails(Index)
    15.     .X = X
    16.     .Y = Y
    17.     .Width = Picture1.Width
    18.     .Height = Picture1.Height
    19.   End With
    20. End Sub
    21.  
    22. Private Sub Image1_MouseMove(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
    23.   Static Busy As Boolean
    24.   If Not Busy Then
    25.     Busy = True
    26.     If Button And vbLeftButton Then
    27.       ResizePicture Index, X, Y
    28.     End If
    29.     Busy = False
    30.   End If
    31. End Sub
    32. '
    33. ' ...
    34. '
    35. Private Sub ResizeImage(Index As Integer, X As Single, Y As Single)
    36.   With ImageDetails(Index)
    37.     Image1(Index).Move .Width + (X - .X), .Height + (Y - .Y)
    38.   End With
    39.   DoEvents
    40. End Sub
Keep in mind, I just wrote this code right here, so it may need a little debugging.
Aug 7 '07 #6
akynaya
27 New Member
THANK YOU, I'll try this one out
Aug 8 '07 #7
Killer42
8,435 Recognized Expert Expert
THANK YOU, I'll try this one out
Good luck. Let us know how it works out.
Aug 9 '07 #8

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

Similar topics

9
5037
by: lawrence | last post by:
Can someone please tell me where I can get some open source code for resizing images? I know such code has been written a million times and I don't feel like doing it again from scratch.
4
3300
by: Matthias Czapla | last post by:
Hi! I want to resize uploaded GIF images. Currently I do it like this: <?php // ... $img = imagecreatefromgif($path); $img_scaled = imagecreate($new_width, $new_height);...
2
2680
by: Alex Hopson | last post by:
I'm using the code below to loop through some images and resize each image twice, once to create a thumbnail and once to create a small image. The page stops loading around the 38th image out of...
10
2290
by: riki | last post by:
Hi, i have a big problem...i'm using one jscript for resizing of all of my pics in popUp...in main html i'm having many little pics and clicking on them they open in popUp and resize to larger...
9
32028
by: Bryan R. Meyer | last post by:
Hello Everyone, The problem of browser resizing has become an issue for me. While redesigning my webpage, I set the left and right margins to be auto so that my content would be centered. ...
13
6865
by: Jon Yeager | last post by:
I need to display a bunch of pictures that are all of various dimensions into a fixed dimension space, like MSN Messenger does with its user photos in the chat windows. Forcing image dimensions...
5
4720
by: Jim | last post by:
I've heard that resizing images through PHP (either GD2 or ImageMagick) is a processor intensive exercise. I'm setting up a site where users will be uploading up to 10 images along with the details...
1
2113
by: Ron Vecchi | last post by:
I am using asp.net to upload an image and then perform resizing on it and saving the different sizes to file. The resized images were coming up and being displayed in the bowser fine but the image...
6
2252
by: tomasio | last post by:
Dear NG, years have passed and I am still more designer than programmer. I build a new version of my website which has a few nasty bugs, especially on my startpage: Resizing text brakes the...
10
7043
by: mishrarajesh44 | last post by:
hii all, I am facing a problem currently.. i have a script for image uploading and resizing.. the image uploading takes place properly for every size images.. but, the resizing works for...
0
7229
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
7129
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
7333
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7061
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
5637
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,...
1
5057
isladogs
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...
0
3208
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1566
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 ...
1
769
muto222
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.