Click here to Skip to main content
15,914,016 members
Home / Discussions / Visual Basic
   

Visual Basic

 
Question[Message Deleted] Pin
campbells27-Mar-06 3:16
campbells27-Mar-06 3:16 
AnswerRe: how to save the image path to txt? Pin
albCode27-Mar-06 4:02
albCode27-Mar-06 4:02 
AnswerRe: how to save the image path to txt? Pin
Guffa27-Mar-06 7:19
Guffa27-Mar-06 7:19 
AnswerRe: Save and load from .txt file Pin
Christian Graus27-Mar-06 8:47
protectorChristian Graus27-Mar-06 8:47 
Generalproblem solve!! ya huuuuuuuu Pin
campbells27-Mar-06 17:57
campbells27-Mar-06 17:57 
QuestionInternet explorer script error!!!! Pin
Hari Om Prakash Sharma27-Mar-06 0:38
Hari Om Prakash Sharma27-Mar-06 0:38 
AnswerRe: Internet explorer script error!!!! Pin
Dave Kreskowiak27-Mar-06 6:04
mveDave Kreskowiak27-Mar-06 6:04 
QuestionCreate Image object from Graphics object - how? Pin
nzmike26-Mar-06 23:26
nzmike26-Mar-06 23:26 
Hi all,

I have a little app I'm writing to crop images and so far it works - except that once I've created a cropped version of my original image (as a Bitmap or Graphics object) I can't then convert it into an Image object to reshow in my PictureBox control.

Some background: first I load the jpeg image into an Image object then assign it to the PictureBox. I then use the MouseUp, MouseDrag and MouseDown events to allow the user to draw a rectangle on the PictureBox.... when the user clicks a crop button I do the code below:

Dim x, y, w, h As Single

'These variables are from the mouse positions caught with MouseUp and MouseDown
'on the PictureBox control which is showing the image loaded from a JPG file.
'They define the rectangle the user has drawn on the Image in the PictureBox.
x = intMouseXStart
y = intMouseYStart
x2 = intMouseXEnd
y2 = intMouseYEnd
w = intMouseXEnd - intMouseXStart
h = intMouseYEnd - intMouseYStart

'Get the source bitmap from the PictureBox control.
Dim bm_source As New Bitmap(picImage.Image)

' Create parallelogram for extracting original image.
Dim ulCorner1 As New PointF(x, y)
Dim urCorner1 As New PointF(x2, y)
Dim llCorner1 As New PointF(x, y2)
Dim destPara1 As PointF() = {ulCorner1, urCorner1, llCorner1}

'Create rectangle as the size of the source area of the image to crop
Dim srcRect As New RectangleF(x, y, w, h)

'Clear the PictureBox and display the cropped image
Dim g As Graphics = Graphics.FromHwnd(picImage.Handle)
g.Clear(picImage.BackColor)
g.DrawImage(bm_source, destPara1, srcRect, GraphicsUnit.Pixel)

So, basically I want to take what the last line above does and create an Image object out of it so I can then reassign it to the PictureBox control and do other stuff with it... I've tried all sorts of things but can't work it out - any help would be appreciated.

TIA...

Mike

-- modified at 5:32 Monday 27th March, 2006
AnswerRe: Create Image object from Graphics object - how? Pin
Guffa26-Mar-06 23:35
Guffa26-Mar-06 23:35 
GeneralRe: Create Image object from Graphics object - how? Pin
nzmike27-Mar-06 19:51
nzmike27-Mar-06 19:51 
AnswerRe: Create Image object from Graphics object - how? Pin
Guffa30-Mar-06 0:57
Guffa30-Mar-06 0:57 
QuestionDate by Week nr? Pin
Snowjim26-Mar-06 22:45
Snowjim26-Mar-06 22:45 
AnswerRe: Date by Week nr? Pin
sathish s27-Mar-06 0:58
sathish s27-Mar-06 0:58 
GeneralRe: Date by Week nr? Pin
Snowjim27-Mar-06 19:18
Snowjim27-Mar-06 19:18 
GeneralRe: Date by Week nr? Pin
Snowjim27-Mar-06 19:19
Snowjim27-Mar-06 19:19 
GeneralRe: Date by Week nr? Pin
Snowjim27-Mar-06 19:19
Snowjim27-Mar-06 19:19 
GeneralRe: Date by Week nr? Pin
sathish s27-Mar-06 19:57
sathish s27-Mar-06 19:57 
Questionlogon times Pin
denis7426-Mar-06 22:37
denis7426-Mar-06 22:37 
AnswerRe: logon times Pin
Dave Kreskowiak27-Mar-06 5:52
mveDave Kreskowiak27-Mar-06 5:52 
GeneralRe: logon times Pin
denis7428-Mar-06 0:18
denis7428-Mar-06 0:18 
GeneralRe: logon times Pin
Dave Kreskowiak28-Mar-06 2:53
mveDave Kreskowiak28-Mar-06 2:53 
QuestionIO stream and arabic Pin
illusionFinder26-Mar-06 22:24
illusionFinder26-Mar-06 22:24 
AnswerRe: IO stream and arabic Pin
albCode26-Mar-06 22:36
albCode26-Mar-06 22:36 
AnswerRe: IO stream and arabic Pin
Guffa26-Mar-06 22:51
Guffa26-Mar-06 22:51 
GeneralRe: IO stream and arabic Pin
illusionFinder26-Mar-06 22:59
illusionFinder26-Mar-06 22:59 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.