Results 1 to 8 of 8

Thread: How do I import an image

  1. #1

    Thread Starter
    Junior Member RepoBounty's Avatar
    Join Date
    Jun 2002
    Location
    ILLINOIS
    Posts
    23

    How do I import an image

    How do I import an image? I want to make a simple slide show Application. It would have the normal buttons and scroll thru family photos.

    Do I have to DIM the image before I can make it show up when the button is clicked? And it has to be imported some how to the Application ………. is that Correct?

    I know it is simple for most out there and maybe someone has one they could let me learn from or some code you can send me.



    Sorry I am very new at this.

  2. #2
    Hyperactive Member
    Join Date
    Dec 2002
    Posts
    382
    You could just store the images in a bitmap then display them.

    Dim myBmp as New BitMap("c:\images\myimg.bmp")

    depending on where you want to display them is where you would copy them, if you want to display them on the main form, just do

    Dim myBmp as New BitMap("c:\images\myimg.bmp")
    Dim G as Graphics = Me.CreateGraphics
    G.DrawImage(myBmp, 0 0)

    Hope that helps..

  3. #3
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    Originally posted by Hinder
    You could just store the images in a bitmap then display them.

    Dim myBmp as New BitMap("c:\images\myimg.bmp")

    depending on where you want to display them is where you would copy them, if you want to display them on the main form, just do

    Dim myBmp as New BitMap("c:\images\myimg.bmp")
    Dim G as Graphics = Me.CreateGraphics
    G.DrawImage(myBmp, 0 0)

    Hope that helps..
    and remember G.Dispose() at the end (and myBmp.dispose()? )

    edit: btw why dont you just say me.backgroundimage = myBmp? that way you dont even need to worry about the paint event
    Last edited by MrPolite; Jan 11th, 2003 at 09:54 PM.
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  4. #4
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    myPic.Image = Image.FromFile("C:\...")

    i dont remember if it is myPic.Image or myPic.Picture sorry
    \m/\m/

  5. #5

    Thread Starter
    Junior Member RepoBounty's Avatar
    Join Date
    Jun 2002
    Location
    ILLINOIS
    Posts
    23
    Ok here is what i have
    ===========================


    Public Class Form1
    Inherits System.Windows.Forms.Form

    #Region " Windows Form Designer generated code "

    Public Sub New()
    MyBase.New()

    'This call is required by the Windows Form Designer.
    InitializeComponent()

    'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
    If disposing Then
    If Not (components Is Nothing) Then
    components.Dispose()
    End If
    End If
    MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.
    'Do not modify it using the code editor.
    Friend WithEvents ImageList1 As System.Windows.Forms.ImageList
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
    Me.components = New System.ComponentModel.Container()
    Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(Form1))
    Me.ImageList1 = New System.Windows.Forms.ImageList(Me.components)
    '
    'ImageList1
    '
    Me.ImageList1.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit
    Me.ImageList1.ImageSize = New System.Drawing.Size(16, 16)
    Me.ImageList1.ImageStream = CType(resources.GetObject("ImageList1.ImageStream"), System.Windows.Forms.ImageListStreamer)
    Me.ImageList1.TransparentColor = System.Drawing.Color.Transparent
    '
    'Form1
    '
    Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
    Me.ClientSize = New System.Drawing.Size(552, 266)
    Me.Name = "Form1"
    Me.Text = "Form1"

    End Sub

    #End Region


    Private Sub
    TextArea_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles TextArea.Paint

    Dim myBmp As New Bitmap("C:\Documents and Settings\ROBERT\My Documents\My Pictures/car.jpg")
    Dim G As Graphics = Me.CreateGraphics
    G.DrawImage()("myBmp, 0 ")


    'End Sub
    End Class


    ===========================
    Error I get

    Identifier expected.

    ==================


    Something Is Wrong !

  6. #6
    Hyperactive Member
    Join Date
    Dec 2002
    Posts
    382
    TextArea_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles TextArea.Paint

    Dim myBmp As New Bitmap("C:\Documents and Settings\ROBERT\My Documents\My Pictures\car.jpg")
    Dim G As Graphics = Me.CreateGraphics
    G.DrawImage(myBmp, 0, 0)

    Try That

  7. #7

    Thread Starter
    Junior Member RepoBounty's Avatar
    Join Date
    Jun 2002
    Location
    ILLINOIS
    Posts
    23
    Here is the error i am getting now the code in blue at the bottom is where the Swigglly line is
    =======================

    C:\Projects\WindowsApplication6\Form1.vb(46): Handles clause requires a WithEvents variable.

    ================================


    HERE IS THE CODE


    ====================

    Public Class Form1
    Inherits System.Windows.Forms.Form

    #Region " Windows Form Designer generated code "

    Public Sub New()
    MyBase.New()

    'This call is required by the Windows Form Designer.
    InitializeComponent()

    'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
    If disposing Then
    If Not (components Is Nothing) Then
    components.Dispose()
    End If
    End If
    MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.
    'Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
    '
    'Form1
    '
    Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
    Me.ClientSize = New System.Drawing.Size(292, 266)
    Me.Name = "Form1"
    Me.Text = "Form1"

    End Sub

    #End Region


    Private Sub TextArea_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles TextArea .Paint

    Dim myBmp As New Bitmap("C:\Documents and Settings\ROBERT\My Documents\My Pictures\car.jpg")
    Dim G As Graphics = Me.CreateGraphics
    G.DrawImage(myBmp, 0, 0)
    End Sub
    End Class

  8. #8
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    for a class support events u must put withevents instead of dim on the var that will instantiate that...i dont do vb.net a while ago so i cant see where it is but i think that that is what the error is saying about..
    \m/\m/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width