Adding points to a bitmap

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • John Dann

    #1

    Adding points to a bitmap

    I've never had much cause to read up in detail on GDI+ but there's a
    small piece of a project where I need to add some annotation (let's
    say just some small filled rectangles as markers) to a pre-existing
    bitmap and then resave the bitmap. I've tried several ways of doing
    this but they either don't work or give errors. Anyone able to help me
    out please?

    The sort of thing I'm doing is:

    Dim MyBMP as Bitmap = Bitmap.Fromfile (MyFileLocation )

    then I've tried eg

    Dim gr as graphics = MyBMP.Creategra phics

    but get a runtime error that I can't use a bitmap with indexed pixels.

    I was then simply hoping to be able to say:

    gr.FillRectangl e(brushdetails, rectangledetail s)

    MyBMP.Save(Anno tatedFile)

    I could go on with the various bits of code I've tried but while I'm
    presuming that there is a simple approach to this, my attempts
    obviously haven't hit on the right combination.

    Thanks for any help.
    JGD
  • John Dann

    #2
    Re: Adding points to a bitmap

    Anyone able to help please?

    JGD

    Comment

    • Larry Lard

      #3
      Re: Adding points to a bitmap



      John Dann wrote:[color=blue]
      > I've never had much cause to read up in detail on GDI+ but there's a
      > small piece of a project where I need to add some annotation (let's
      > say just some small filled rectangles as markers) to a pre-existing
      > bitmap and then resave the bitmap. I've tried several ways of doing
      > this but they either don't work or give errors. Anyone able to help me
      > out please?
      >
      > The sort of thing I'm doing is:
      >
      > Dim MyBMP as Bitmap = Bitmap.Fromfile (MyFileLocation )
      >
      > then I've tried eg
      >
      > Dim gr as graphics = MyBMP.Creategra phics
      >
      > but get a runtime error that I can't use a bitmap with indexed pixels.[/color]

      This seems to be the heart of the problem. From what I have read,
      bitmap formats with indexed colors are not given equal treatment by
      GDI+. If possible, I would suggest having the original image altered
      into a non-indexed bitmap format (eg 24 bits per pixel), then you will
      be able to do

      Dim gr As Graphics = Graphics.FromIm age(MyBMP)

      and proceed as you had intended.

      You might find more useful info at Bob Powell's GDI+ site (google).

      --
      Larry Lard
      Replies to group please

      Comment

      • Supra

        #4
        Re: Adding points to a bitmap



        John Dann wrote:
        [color=blue]
        >I've never had much cause to read up in detail on GDI+ but there's a
        >small piece of a project where I need to add some annotation (let's
        >say just some small filled rectangles as markers) to a pre-existing
        >bitmap and then resave the bitmap. I've tried several ways of doing
        >this but they either don't work or give errors. Anyone able to help me
        >out please?
        >
        >The sort of thing I'm doing is:
        >
        >Dim MyBMP as Bitmap = Bitmap.Fromfile (MyFileLocation )
        >
        >then I've tried eg
        >
        >Dim gr as graphics = MyBMP.Creategra phics
        >
        >but get a runtime error that I can't use a bitmap with indexed pixels.
        >
        >I was then simply hoping to be able to say:
        >
        >gr.FillRectang le(brushdetails , rectangledetail s)
        >
        >MyBMP.Save(Ann otatedFile)
        >
        >I could go on with the various bits of code I've tried but while I'm
        >presuming that there is a simple approach to this, my attempts
        >obviously haven't hit on the right combination.
        >
        >Thanks for any help.
        >JGD
        >
        >[/color]

        Comment

        Working...