Sign in to follow this  
nerosky

Anyone can help me with this...??

Recommended Posts

Im now doing the image processing on BOrland C++ Builder 5... I have capture an image and store the data in a buffer.. But my problem now will to show the image on a form... There is a template TImage in this builder but this template only show/display image from a file and not a buffer.. Is there any way to display the image directly from the buffer or an array in this C++ Builder..??

Share this post


Link to post
Share on other sites
Here is how I would make an image buffer in C++ Builder

// Create a 640x480 buffer:

#include "Graphics.hpp"
...
Graphics::TBitmap* bitmap = new Graphics::TBitmap();
bitmap->Width = 640;
bitmap->Height = 480;


// Make pixel 10,10 red:

bitmap->Canvas->Pixels[10][10] = clRed;
// or
bitmap->Canvas->Pixels[10][10] = TColor(255, 0, 0);

// After filling the bitmap->Canvas with whatever, you can copy it to another Canvas:

Image1->Stretch = true;
Image1->Picture->Graphic = bitmap;
Image1->Canvas->Draw(0, 0, bitmap);

// or if you need a bit more control
Image1->Canvas->CopyMode = cmSrcCopy;
Image1->Canvas->CopyRect(...);

The canvas object has all the good stuff. I think Builder will show you a drop down list so you can see for yourself.
For example, here is how to draw a blue line on our bitmap:

bitmap->Canvas->Pen->Color = clBlue;
bitmap->Canvas->MoveTo(10, 10);
bitmap->Canvas->LineTo(100, 100);


Something along these lines.

[Edited by - pulpfist on April 6, 2007 10:14:18 AM]

Share this post


Link to post
Share on other sites
Quote:
Original post by pulpfist
Here is how I would make an image buffer in C++ Builder

// Create a 640x480 buffer:

#include "Graphics.hpp"
...
Graphics::TBitmap* bitmap = new Graphics::TBitmap();
bitmap->Width = 640;
bitmap->Height = 480;


// Make pixel 10,10 red:

bitmap->Canvas->Pixels[10][10] = clRed;
// or
bitmap->Canvas->Pixels[10][10] = TColor(255, 0, 0);

// After filling the bitmap->Canvas with whatever, you can copy it to another Canvas:

Image1->Stretch = true;
Image1->Picture->Graphic = bitmap;
Image1->Canvas->Draw(0, 0, bitmap);

// or if you need a bit more control
Image1->Canvas->CopyMode = cmSrcCopy;
Image1->Canvas->CopyRect(...);

The canvas object has all the good stuff. I think Builder will show you a drop down list so you can see for yourself.
For example, here is how to draw a blue line on our bitmap:

bitmap->Canvas->Pen->Color = clBlue;
bitmap->Canvas->MoveTo(10, 10);
bitmap->Canvas->LineTo(100, 100);


Something along these lines.




Thanks man... this has being really helpfull... i manage to grab the image ald.. thanks again :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this