Board index » cppbuilder » What is the fastest way to get Bitmap to char foo[x][y] and back

What is the fastest way to get Bitmap to char foo[x][y] and back

May seem a simple question but I need to get bitmap data loaded in memory to
an array of char[x][y] in very quick execute time, for image analysis.
(actually three arrays, one for red, green, blue or an extra dimension in
one array, haven't decided yet).

I've got as far as figuring it's GDI, but have never had the need to do API
functions before, and am all at sea.

I couldn't get Bitmap->Scanline to work.

Is there a good api tutorial/reference somewhere, so I don't have to harass
you with starter questions?

David Bell

 

Re:What is the fastest way to get Bitmap to char foo[x][y] and back


On Sat, 6 Oct 2001 16:58:04 +1000, "David Bell" <dbell-...@m140.aone.net.au>
wrote:

Quote
>May seem a simple question but I need to get bitmap data loaded in memory to
>an array of char[x][y] in very quick execute time, for image analysis.
>(actually three arrays, one for red, green, blue or an extra dimension in
>one array, haven't decided yet).

>I've got as far as figuring it's GDI, but have never had the need to do API
>functions before, and am all at sea.

>I couldn't get Bitmap->Scanline to work.

>Is there a good api tutorial/reference somewhere, so I don't have to harass
>you with starter questions?

Hi David,

    have a look at this simple snippet:

// 'Bitmap' refers to your bitmap object  
// We are assuming that bitmap->PixelFormat == pf24bit
Graphics::TBitmap* const Bitmap = ..?.?..?..?..;

for ( int y( Bitmap->Height - 1 ) ; y >= 0 ; --y ) {
    TRGBTriple* const Line( static_cast<TRGBTriple*>( Bitmap->ScanLine[y] ) );

    for ( int x( Bitmap->Width - 1 ) ; x >= 0 ; --x ) {
        const TRGBTriple& Pixel( Line[x] );
        // Below, there's the three color components. You can use
        // them as 'right-values' in your expressions
        Pixel.rgbtBlue;
        Pixel.rgbtRed;
        Pixel.rgbtGreen;
    }

Quote
}

HTH

Ciao!

Giuliano

Re:What is the fastest way to get Bitmap to char foo[x][y] and back


Thanks. Works well.
David

Quote
Giuliano <gcardin...@remove.adhoc.net> wrote in message

news:3bbec7d4.80287327@newsgroups.borland.com...
Quote
> On Sat, 6 Oct 2001 16:58:04 +1000, "David Bell"

<dbell-...@m140.aone.net.au>
Quote
> wrote:

> >May seem a simple question but I need to get bitmap data loaded in memory
to
> >an array of char[x][y] in very quick execute time, for image analysis.
> >(actually three arrays, one for red, green, blue or an extra dimension in
> >one array, haven't decided yet).

> >I've got as far as figuring it's GDI, but have never had the need to do
API
> >functions before, and am all at sea.

> >I couldn't get Bitmap->Scanline to work.

> >Is there a good api tutorial/reference somewhere, so I don't have to
harass
> >you with starter questions?

> Hi David,

>     have a look at this simple snippet:

> // 'Bitmap' refers to your bitmap object
> // We are assuming that bitmap->PixelFormat == pf24bit
> Graphics::TBitmap* const Bitmap = ..?.?..?..?..;

> for ( int y( Bitmap->Height - 1 ) ; y >= 0 ; --y ) {
>     TRGBTriple* const

Line( static_cast<TRGBTriple*>( Bitmap->ScanLine[y] ) );

- Show quoted text -

Quote

>     for ( int x( Bitmap->Width - 1 ) ; x >= 0 ; --x ) {
>         const TRGBTriple& Pixel( Line[x] );
>         // Below, there's the three color components. You can use
>         // them as 'right-values' in your expressions
>         Pixel.rgbtBlue;
>         Pixel.rgbtRed;
>         Pixel.rgbtGreen;
>     }
> }

> HTH

> Ciao!

> Giuliano

Other Threads