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. Web Development
  3. ASP.NET
  4. Why doesn't this work?

Why doesn't this work?

Scheduled Pinned Locked Moved ASP.NET
graphicsquestion
7 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.
  • R Offline
    R Offline
    Ranger49
    wrote on last edited by
    #1

    I had this working in my project, then I wanted to use this code in another project and now it refuses to save a BMP file. Please someone tell my what I overlook. Ranger. float range = 1.5F; float startRe = -0.7F; float startIm = 0.27015F; int startColor = 60; public Bitmap objBitmap = new Bitmap(300, 300); public Graphics objGraphic; public Pen myPen = new Pen(Color.Red); protected void enterButton_Click(object sender, EventArgs e) { if (Page.IsValid) { objGraphic = Graphics.FromImage(objBitmap); MakeJuliaSetBmp(); // Do the drawing Response.ContentType = "image/bmp"; MakeUniqueFileName(); // makes a unique filename for the BMP file objBitmap.Save(Request.PhysicalApplicationPath + "/pictures/" + filename, ImageFormat.Bmp); Response.Flush(); objGraphic.Dispose(); objBitmap.Dispose(); myPen.Dispose(); } } Novice

    N C 2 Replies Last reply
    0
    • R Ranger49

      I had this working in my project, then I wanted to use this code in another project and now it refuses to save a BMP file. Please someone tell my what I overlook. Ranger. float range = 1.5F; float startRe = -0.7F; float startIm = 0.27015F; int startColor = 60; public Bitmap objBitmap = new Bitmap(300, 300); public Graphics objGraphic; public Pen myPen = new Pen(Color.Red); protected void enterButton_Click(object sender, EventArgs e) { if (Page.IsValid) { objGraphic = Graphics.FromImage(objBitmap); MakeJuliaSetBmp(); // Do the drawing Response.ContentType = "image/bmp"; MakeUniqueFileName(); // makes a unique filename for the BMP file objBitmap.Save(Request.PhysicalApplicationPath + "/pictures/" + filename, ImageFormat.Bmp); Response.Flush(); objGraphic.Dispose(); objBitmap.Dispose(); myPen.Dispose(); } } Novice

      N Offline
      N Offline
      Not Active
      wrote on last edited by
      #2

      Ranger49 wrote:

      now it refuses to save

      What do you mean? An exception is thrown? The files isn't created? Are you sure the proper rights have been assigned to the destination folder?


      only two letters away from being an asset

      1 Reply Last reply
      0
      • R Ranger49

        I had this working in my project, then I wanted to use this code in another project and now it refuses to save a BMP file. Please someone tell my what I overlook. Ranger. float range = 1.5F; float startRe = -0.7F; float startIm = 0.27015F; int startColor = 60; public Bitmap objBitmap = new Bitmap(300, 300); public Graphics objGraphic; public Pen myPen = new Pen(Color.Red); protected void enterButton_Click(object sender, EventArgs e) { if (Page.IsValid) { objGraphic = Graphics.FromImage(objBitmap); MakeJuliaSetBmp(); // Do the drawing Response.ContentType = "image/bmp"; MakeUniqueFileName(); // makes a unique filename for the BMP file objBitmap.Save(Request.PhysicalApplicationPath + "/pictures/" + filename, ImageFormat.Bmp); Response.Flush(); objGraphic.Dispose(); objBitmap.Dispose(); myPen.Dispose(); } } Novice

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

        Ranger49 wrote:

        public Bitmap objBitmap = new Bitmap(300, 300); public Graphics objGraphic; public Pen myPen = new Pen(Color.Red);

        Why are these public ? Why are they members at all ?

        Ranger49 wrote:

        MakeUniqueFileName

        Why does this not return the filename ? It's probable you don't have write permissions on the folder, or it doesn't exist. Hard to say without seeing the error

        Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

        R 1 Reply Last reply
        0
        • C Christian Graus

          Ranger49 wrote:

          public Bitmap objBitmap = new Bitmap(300, 300); public Graphics objGraphic; public Pen myPen = new Pen(Color.Red);

          Why are these public ? Why are they members at all ?

          Ranger49 wrote:

          MakeUniqueFileName

          Why does this not return the filename ? It's probable you don't have write permissions on the folder, or it doesn't exist. Hard to say without seeing the error

          Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

          R Offline
          R Offline
          Ranger49
          wrote on last edited by
          #4

          The problem is that the enterButton_Click method (which should call a class to compute a fractal which then saves it to a Bmp pic file) never runs. Also my codefile in the App_Code ProduceImageFile.cs never is even run. I wanted the enter.aspx to call the ProduceImageFile.cs but somehow that never happens. In enter.aspx is a startButton_Click method which also never seems to fire, even though it does move you to the display.aspx which is intended to display the computed picture, the wanted calculations are never made on this click. So there may not be any bugs in the code where I expected it, this code never is reached and executed! About the App_Code folder, do you need to do something with the namespace or something to make sure the aspx (cs) file can find it? Hope this is clearer now. Thanks everybody. Ranger. Novice

          C 1 Reply Last reply
          0
          • R Ranger49

            The problem is that the enterButton_Click method (which should call a class to compute a fractal which then saves it to a Bmp pic file) never runs. Also my codefile in the App_Code ProduceImageFile.cs never is even run. I wanted the enter.aspx to call the ProduceImageFile.cs but somehow that never happens. In enter.aspx is a startButton_Click method which also never seems to fire, even though it does move you to the display.aspx which is intended to display the computed picture, the wanted calculations are never made on this click. So there may not be any bugs in the code where I expected it, this code never is reached and executed! About the App_Code folder, do you need to do something with the namespace or something to make sure the aspx (cs) file can find it? Hope this is clearer now. Thanks everybody. Ranger. Novice

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

            Ranger49 wrote:

            About the App_Code folder, do you need to do something with the namespace or something to make sure the aspx (cs) file can find it?

            No. How are the buttons hooked up to events ? If they are created on the fly, they need to be created in the LoadViewState event, so that they exist when view state is restored, and their events are not lost.

            Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

            R 1 Reply Last reply
            0
            • C Christian Graus

              Ranger49 wrote:

              About the App_Code folder, do you need to do something with the namespace or something to make sure the aspx (cs) file can find it?

              No. How are the buttons hooked up to events ? If they are created on the fly, they need to be created in the LoadViewState event, so that they exist when view state is restored, and their events are not lost.

              Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

              R Offline
              R Offline
              Ranger49
              wrote on last edited by
              #6

              Christian Graus wrote:

              How are the buttons hooked up to events ?

              I only got a enterButton_Click method. Is there a LoadViewState event in the properties window of the button? I couldn't find it. Ranger. Novice

              R 1 Reply Last reply
              0
              • R Ranger49

                Christian Graus wrote:

                How are the buttons hooked up to events ?

                I only got a enterButton_Click method. Is there a LoadViewState event in the properties window of the button? I couldn't find it. Ranger. Novice

                R Offline
                R Offline
                Ranger49
                wrote on last edited by
                #7

                As it turned out the code was never even reached. So I made an instance of the class that should generate a bmp file in the Page_Load handler of my enter.aspx. Now it did run, but now I get the message: Response.ContentType = "image/bmp"; not available in this context...! Which is the ProduceImageFile.cs (a class file)I checked all using statements, and I think I got all the ones I need. When you type R you get Response and then you type '.' and C and get Response.ContentType, so I feel this should be available, but for some reason I get an exception that my application cannot handle the Response.ContextType = "image/bmp"; statement. Could anybody tell me how to fix this? It is kind of frustrating to have to spend days on simple things that don't want to work, simply because all those online help files only address the hard issues. I tried these concepts in small projects and got them to run properly, then I tried to encorporate them in a larger application and again it refuses to function! Ranger. Novice.

                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