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
  1. Home
  2. General Programming
  3. C#
  4. how to put a Button Image into an array?

how to put a Button Image into an array?

Scheduled Pinned Locked Moved C#
databasedata-structureshelptutorialquestion
2 Posts 2 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.
  • K Offline
    K Offline
    Khoramdin
    wrote on last edited by
    #1

    Hello everyone, I use the following code to place an image "temp.jpeg" into an array and then write the array into a remote database. int FileSize; byte[] ImageArray; FileStream fs; int iBytesRead; // 1. OpenFileName = "temp.jpeg"; // 2. By using FileStream object, fill the byte array. fs = new FileStream(OpenFileName, FileMode.Open, FileAccess.Read, FileShare.Read); FileSize = Convert.ToInt32(fs.Length); // 3. Declare an array of that size. ImageArray = new byte[FileSize]; iBytesRead = fs.Read(ImageArray, 0, FileSize); fs.Close(); I was wonder what I should do if the image is not a file such as "temp.jpeg" and it is the image displayed in a Button? Can someone be kind enough to help me out on this one? Thank you very much and have a great day. Khoramdin

    A 1 Reply Last reply
    0
    • K Khoramdin

      Hello everyone, I use the following code to place an image "temp.jpeg" into an array and then write the array into a remote database. int FileSize; byte[] ImageArray; FileStream fs; int iBytesRead; // 1. OpenFileName = "temp.jpeg"; // 2. By using FileStream object, fill the byte array. fs = new FileStream(OpenFileName, FileMode.Open, FileAccess.Read, FileShare.Read); FileSize = Convert.ToInt32(fs.Length); // 3. Declare an array of that size. ImageArray = new byte[FileSize]; iBytesRead = fs.Read(ImageArray, 0, FileSize); fs.Close(); I was wonder what I should do if the image is not a file such as "temp.jpeg" and it is the image displayed in a Button? Can someone be kind enough to help me out on this one? Thank you very much and have a great day. Khoramdin

      A Offline
      A Offline
      alexey N
      wrote on last edited by
      #2

      You can save the image displayed in a Button to temporary file, and after that read from this file. Or you can save this image to stream, and then read it's data to array.

      My english is not so good. Please, correct my errors. Best regards, Alexey.

      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