473,397 Members | 2,056 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

"Rubber Band" Problem

I got one too hard for me to fix problem. I know the cause and i know why
but i cant fix it.
I am using a "Rubber band" like function, drawing a rectangle on an image
in a picturebox that i loaded. Now i want to Cut out the part i marked with
the "Rubber band" and load that image in the picturebox. This works great
and i can save that image as i want to. The problem is that the image loaded
is smaller cause when i load the image i use drawimage from the original image
and redraw it to fit the picturebox. And when i now cut out everything except
the "Rubber band" part it gets smaller cause i use the picturebox verision of
the image and not the original image.Any ideas on how this can be done easily
so i cut from the original image and not the picturebox image wich is smaller.
and if i cut from the original image the rectangle will be too small aswell.


hard to explain, hope you will understand.

iam using Microsoft visual basic.net 2003

Expand|Select|Wrap|Line Numbers
  1. 'Part of the load image code
  2. tempx = PictureBox1.Width
  3. tempy = PictureBox1.Height
  4. Dim tempbmp As New Bitmap(tempx, tempy) 
  5. Dim g As Graphics = graphics.FromImage(tempbmp) 
  6. g.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic
  7. g.DrawImage(tempbitmap, New Rectangle(0, 0, tempx, tempy), New Rectangle(0, 0, tempbitmap.Width, tempbitmap.Height), GraphicsUnit.Pixel)
  8. g.Dispose()
  9. PictureBox1.Image = tempbmp
  10. imageloaded = True
  11. loadedbitmap = tempbmp
  12.  
  13. 'Button to cut out the Marked image
  14.  
  15. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  16.  
  17. If marked = True Then
  18. marked = False
  19. Dim tempbmp As New Bitmap(DrawREC.Width, DrawREC.Height)
  20. Dim g As Graphics = graphics.FromImage(tempbmp)
  21. g.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic
  22. g.DrawImage(loadedbitmap, New Rectangle(0, 0, DrawREC.Width, DrawREC.Height), New Rectangle(DrawREC.X, DrawREC.Y, DrawREC.Width, DrawREC.Height), GraphicsUnit.Pixel)
  23. g.Dispose()
  24. loadedbitmap = tempbmp
  25. PictureBox1.Image = tempbmp
  26. imageloaded = True
  27.         End If
  28.     End Sub
  29.  
  30. 'Save the new image sub
  31. Private Sub SaveNewImage()
  32. Dim filename As String = GetFileNameWithoutExtension(path)
  33. Dim newbm As New Bitmap(loadedbitmap)
  34. newbm.Save(filename, ImageFormat.Jpeg)
  35.     End Sub
  36.  
Dec 29 '06 #1
0 1539

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

Similar topics

40
by: Greg G | last post by:
http://risky-biz.com/new/risky.html I finally got DSL service recently, but I haven't forgotten the agony of waiting for the 64th image to load before I can see ANYTHING on a page. So I will...
3
by: Greg G | last post by:
We have a band web site. Here's the site now: http://www.risky-biz.com The home page has a "collage" of photos of the members of the band. The collage is actually one .gif image that I put...
3
by: Phil Powell | last post by:
'GET THE HTML CONTENT FOR DISPLAY BAND ORIGIN Dim bandOriginDropdown On Error Resume Next set scraper = Server.CreateObject("Microsoft.XMLHTTP") if err then bandOriginDropdown = "" else...
14
by: TomB | last post by:
Hello, Let's say I have the following code: <img src="/path/to/little/decorative/graphic"><a href="/link/path">Link</a> When I now make my browser window smaller eventually the graphic and...
10
by: Steven Matthew Bennett | last post by:
I don't know about the rest of the posters, but I came to this NG to learn more about Access, not to have some idiot homophobic dipshit spewing hate with every post. You have nothing to add to...
388
by: maniac | last post by:
Hey guys, I'm new here, just a simple question. I'm learning to Program in C, and I was recommended a book called, "Mastering C Pointers", just asking if any of you have read it, and if it's...
43
by: markryde | last post by:
Hello, I saw in some open source projects a use of "!!" in "C" code; for example: in some header file #define event_pending(v) \ (!!(v)->vcpu_info->evtchn_upcall_pending & \...
8
by: stephane8 | last post by:
I'm able to open and read my .csv file. But when the character "-" is in one of my fields (ex : 18802-002) I get a system.DBNull value ! Even if I edit the file with notepad and put "18802-002" I...
84
by: aarklon | last post by:
Hi all, I found an interesting article here:- http://en.wikipedia.org/wiki/Criticism_of_the_C_programming_language well what do you guys think of this article....??? Is it constructive...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
0
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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,...

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.