Results 1 to 7 of 7

Thread: {Resolved} - Bitmap pixel colour detection

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 2005
    Location
    UK
    Posts
    127

    {Resolved} - Bitmap pixel colour detection

    right i need to import a bitmap that could contain x amount of colours into a picture box

    then divide the bitmap into a grid (made from multiples of 15 x 15 grids)

    analyse the colours in each square n deduce what the average colour content is

    assign a windows colour for that area of the grid

    and the build another graphic from the extracted bitmap data

    any ideas peops ?

    this ones puddlin me
    Last edited by illskills; Jan 1st, 2006 at 05:01 PM. Reason: resolved

  2. #2

    Thread Starter
    Lively Member
    Join Date
    Dec 2005
    Location
    UK
    Posts
    127

    Re: Bitmap pixel colour detection

    bump

  3. #3
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Re: Bitmap pixel colour detection

    Sounds like you are resampling an image to make it smaller or pixellate it, is that right?

    Fastest way is to lock the bitmap into memory using Bitmap.LockBits(). Then you copy the data into an array and scan it with a loop.

    This way is much harder to implement (if you are not used to this kind of thing) so you might find using Bitmap.GetPixel() easier until you get into the swing of things.

    Good luck getting a detailed answer in the next 72 hours
    I don't live here any more.

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Dec 2005
    Location
    UK
    Posts
    127

    Re: Bitmap pixel colour detection

    im writing a mosaic design program ... need to split the bitmap into its various colours ... have been looking a GetPixel() too ... will check the above out ... many thanks illskills

    if any one else knows of any useful imaging scripts/classes/functions etc would be most helpful

    thanks once again !

  5. #5
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    297

    Re: Bitmap pixel colour detection

    I did a pixelate example on pscode.com
    http://www.pscode.com/vb/scripts/Sho...4029&lngWId=10

    The way I did it was to lock the bitmap with lockbits, then get at the data with marshal.readbyte, and set it again with marshal.writebyte. Since then, I've found that it is faster to define an array to hold the colors and use marshal.copy to move all the data into the array.
    Attached is the pixelate example modified that way (vb2005, I've not got 2003 to hand). If you have 2003 then open the form1.vb and then copy and paste the code into a new project (you'll need to set up the form controls manually, and clean up any 2005 specific stuff).

    To get it faster (vb is limited, so code tweaks will only get it a bit faster) you would need to move to c# or c++. See Christian Graus' articles which are linked to here for a bit on processing in c#
    http://www.bobpowell.net/imageprocessing.htm
    Attached Files Attached Files

  6. #6
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Re: Bitmap pixel colour detection

    You may be interested to know that DoomSharp will eventually (when I finally get around to it) use this DMA (direct memory access) to do all of its graphical rendering at runtime. In tests I've managed to get performance in excess of the GDI+ libraries! MS aren't perfect after all
    I don't live here any more.

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Dec 2005
    Location
    UK
    Posts
    127

    Re: Bitmap pixel colour detection

    that pixelate code looks wicked ill check it tonight many thanks .....

    .... still have a few forms to finish before i look at this image import

    thanks again
    ill skillls

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width