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. Parameter is not valid (with bitmap)

Parameter is not valid (with bitmap)

Scheduled Pinned Locked Moved C#
helpgraphicsperformancetutorialquestion
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.
  • M Offline
    M Offline
    Matjaz xyz
    wrote on last edited by
    #1

    Hi. Why do i get this error when opening a file as bitmap : "Parameter is not valid" I'm trying to open a .tif file, with calling a funtcion. The code:

     Bitmap tif = new Bitmap(fileName, false);
    

    I googled a bit and tried with casting the bitmap like this: "bitmap tif = (bitmap)bitmap.fromfile(filename);" but i got another error saying - "out of memory". i also read something with using stream, but didnt quite get it on how to work... Can someone please help? PS: the tif file has 4 EMPTY pages. And everything stopped only with this file. Many tifs before went through well. Thanks in advance.

    Regards, Matjaž

    H 1 Reply Last reply
    0
    • M Matjaz xyz

      Hi. Why do i get this error when opening a file as bitmap : "Parameter is not valid" I'm trying to open a .tif file, with calling a funtcion. The code:

       Bitmap tif = new Bitmap(fileName, false);
      

      I googled a bit and tried with casting the bitmap like this: "bitmap tif = (bitmap)bitmap.fromfile(filename);" but i got another error saying - "out of memory". i also read something with using stream, but didnt quite get it on how to work... Can someone please help? PS: the tif file has 4 EMPTY pages. And everything stopped only with this file. Many tifs before went through well. Thanks in advance.

      Regards, Matjaž

      H Offline
      H Offline
      Henry Minute
      wrote on last edited by
      #2

      Since you are setting the second param (useIcm, i think) to false, omit it altogether.

      Bitmap tif = new Bitmap(filename);

      If you still get the error, then it is likely that the tif file has been created in an unorthodox (to MS, at least) way. As far as using streams is concerned try something like:

      Bitmap tif = null;
      using (FileStream fs = new FileStream(filename, FileMode.Open))
      {
      tif = new Bitmap(fs);
      }

      Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

      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