Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. Visual Basic
  4. Resize an image

Resize an image

Scheduled Pinned Locked Moved Visual Basic
questiondatabase
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    New_Coder
    wrote on last edited by
    #1

    I am using the following code to save an image into an MSAcess database using VB 2003 How can I resize the image to a fixed size? and two is there a cleaner way to do this Dim STREAM As System.IO.FileStream Dim READER As StreamReader Dim JPEG_FILE As String JPEG_FILE = txtPicFile.Text 'this is the path and file name of image STREAM = New FileStream(JPEG_FILE, FileMode.Open, FileAccess.Read, FileShare.Read) READER = New StreamReader(STREAM) Dim FILEBYTE(STREAM.Length - 1) As Byte STREAM.Read(FILEBYTE, 0, STREAM.Length) 'save image to database using DBS As DAO.Database and RST As DAO.Recordset... .Fields("Image").Value = FILEBYTE

    C G 2 Replies Last reply
    0
    • N New_Coder

      I am using the following code to save an image into an MSAcess database using VB 2003 How can I resize the image to a fixed size? and two is there a cleaner way to do this Dim STREAM As System.IO.FileStream Dim READER As StreamReader Dim JPEG_FILE As String JPEG_FILE = txtPicFile.Text 'this is the path and file name of image STREAM = New FileStream(JPEG_FILE, FileMode.Open, FileAccess.Read, FileShare.Read) READER = New StreamReader(STREAM) Dim FILEBYTE(STREAM.Length - 1) As Byte STREAM.Read(FILEBYTE, 0, STREAM.Length) 'save image to database using DBS As DAO.Database and RST As DAO.Recordset... .Fields("Image").Value = FILEBYTE

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      dim b as Bitmap = new Bitmap(txtPicFile.Text) I'm pretty sure there's another constructor that takes a bitmap and a new size, which you can use to resize it. Then you can access the bits of the bitmap in whatever format you like to write to the database, they are exposed on the bitmap object. Christian Graus - Microsoft MVP - C++

      1 Reply Last reply
      0
      • N New_Coder

        I am using the following code to save an image into an MSAcess database using VB 2003 How can I resize the image to a fixed size? and two is there a cleaner way to do this Dim STREAM As System.IO.FileStream Dim READER As StreamReader Dim JPEG_FILE As String JPEG_FILE = txtPicFile.Text 'this is the path and file name of image STREAM = New FileStream(JPEG_FILE, FileMode.Open, FileAccess.Read, FileShare.Read) READER = New StreamReader(STREAM) Dim FILEBYTE(STREAM.Length - 1) As Byte STREAM.Read(FILEBYTE, 0, STREAM.Length) 'save image to database using DBS As DAO.Database and RST As DAO.Recordset... .Fields("Image").Value = FILEBYTE

        G Offline
        G Offline
        Guffa
        wrote on last edited by
        #3

        That looks pretty straightforward. To resize an image you load the image into a Bitmap object, create a new Bitmap object with the size you want, and draw the first bitmap onto the new one scaled to that size. Save the image to a memorystream so that you easily can get it as a byte array. --- b { font-weight: normal; }

        N 1 Reply Last reply
        0
        • G Guffa

          That looks pretty straightforward. To resize an image you load the image into a Bitmap object, create a new Bitmap object with the size you want, and draw the first bitmap onto the new one scaled to that size. Save the image to a memorystream so that you easily can get it as a byte array. --- b { font-weight: normal; }

          N Offline
          N Offline
          New_Coder
          wrote on last edited by
          #4

          That sound straight forward. How do I do that? I asume you use the dim MyBitmap as bitmap ' creates the object but how do I set the size?

          G 1 Reply Last reply
          0
          • N New_Coder

            That sound straight forward. How do I do that? I asume you use the dim MyBitmap as bitmap ' creates the object but how do I set the size?

            G Offline
            G Offline
            Guffa
            wrote on last edited by
            #5

            New_Coder wrote:

            dim MyBitmap as bitmap ' creates the object

            That only creates a reference to the object. When you create the object you specify the size: MyBitmap = New BitMap(width, height) --- b { font-weight: normal; } -- modified at 13:39 Saturday 25th March, 2006

            N 1 Reply Last reply
            0
            • G Guffa

              New_Coder wrote:

              dim MyBitmap as bitmap ' creates the object

              That only creates a reference to the object. When you create the object you specify the size: MyBitmap = New BitMap(width, height) --- b { font-weight: normal; } -- modified at 13:39 Saturday 25th March, 2006

              N Offline
              N Offline
              New_Coder
              wrote on last edited by
              #6

              How do I get my image into the MyBitmap variable so I can save it back to the MSAccess database at a specific size? Thanks for your help

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups