BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Help with graphic file task

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Graphics
View previous topic :: View next topic  
Author Message
Andy
Guest





PostPosted: Fri Oct 13, 2006 1:25 pm    Post subject: Help with graphic file task Reply with quote



I have an equipment that produces a 24-bit image of a gray background and
black or white pixels. Since it is 24-bit, it has many shades of gray, black
and white. I was told to do the following:

1. ability to change the colors gray, black or white to a user-defined color
2. ability to include/exclude the colors independently so as to show the
gray, black or white alone

In order to do this, I think I need to reduce the colors so there are not
too many shades of gray, black or white but a distinct shade of either gray,
black or white. How do I do this? Once that is accomplished, how do I locate
the range of colors to do the rest, like changing the color or
include/exclude certain colors?

If I need any third-party components to do this easily with examples, I
would be interested too. I thank you in advance for any help.

Andy
Back to top
James Brown
Guest





PostPosted: Fri Oct 13, 2006 10:00 pm    Post subject: Re: Help with graphic file task Reply with quote



Take a look at this site:
http://www.efg2.com/Lab/

He has a lot of Delphi graphic code with source. Good reference.
Regards.. Jim
"Andy" <nospam (AT) prizm (DOT) com> wrote in message
news:452f4d67$1 (AT) newsgroups (DOT) borland.com...
Quote:
I have an equipment that produces a 24-bit image of a gray background and
black or white pixels. Since it is 24-bit, it has many shades of gray,
black
and white. I was told to do the following:

1. ability to change the colors gray, black or white to a user-defined
color
2. ability to include/exclude the colors independently so as to show the
gray, black or white alone

In order to do this, I think I need to reduce the colors so there are not
too many shades of gray, black or white but a distinct shade of either
gray,
black or white. How do I do this? Once that is accomplished, how do I
locate
the range of colors to do the rest, like changing the color or
include/exclude certain colors?

If I need any third-party components to do this easily with examples, I
would be interested too. I thank you in advance for any help.

Andy


Back to top
Peter Below (TeamB)
Guest





PostPosted: Fri Oct 13, 2006 11:11 pm    Post subject: Re: Help with graphic file task Reply with quote



Andy wrote:

Quote:
I have an equipment that produces a 24-bit image of a gray background
and black or white pixels. Since it is 24-bit, it has many shades of
gray, black and white.

Black and white do not have shades, they are *defined* as the colors
with no or all bits set in the RGB color space. Gray in this color
space is any color that has equal amounts of red, blue, gree set, so
there are only 253 shades of gray possible in this color space,
strictly speaking (plus black and white).

Quote:
I was told to do the following:

1. ability to change the colors gray, black or white to a
user-defined color 2. ability to include/exclude the colors
independently so as to show the gray, black or white alone

Alone on what? There has to be a background color.

If you can get your image data into a TBitmap, look at the Scanlines
property. It gives you direct access to the pixel data.


--
Peter Below (TeamB)
Don't be a vampire (http://slash7.com/pages/vampires),
use the newsgroup archives :
http://www.tamaracka.com/search.htm
http://groups.google.com
http://www.prolix.be
Back to top
Andy
Guest





PostPosted: Sat Oct 14, 2006 3:17 am    Post subject: Re: Help with graphic file task Reply with quote

Hi Peter,

Thanks for taking the time to respond.

Sorry for the ignorance on this. I will try to load it into a TBitmap and
muck
around the scanlines property. Do I then try to look at each pixel in the
scanlines
and change the color from there?

Thanks again.

Andy

"Peter Below (TeamB)" <none> wrote in message
news:xn0esfhaz1j6ws001 (AT) newsgroups (DOT) borland.com...
Quote:
Andy wrote:

I have an equipment that produces a 24-bit image of a gray background
and black or white pixels. Since it is 24-bit, it has many shades of
gray, black and white.

Black and white do not have shades, they are *defined* as the colors
with no or all bits set in the RGB color space. Gray in this color
space is any color that has equal amounts of red, blue, gree set, so
there are only 253 shades of gray possible in this color space,
strictly speaking (plus black and white).

I was told to do the following:

1. ability to change the colors gray, black or white to a
user-defined color 2. ability to include/exclude the colors
independently so as to show the gray, black or white alone

Alone on what? There has to be a background color.

If you can get your image data into a TBitmap, look at the Scanlines
property. It gives you direct access to the pixel data.


--
Peter Below (TeamB)
Don't be a vampire (http://slash7.com/pages/vampires),
use the newsgroup archives :
http://www.tamaracka.com/search.htm
http://groups.google.com
http://www.prolix.be
Back to top
Andy
Guest





PostPosted: Sat Oct 14, 2006 3:18 am    Post subject: Re: Help with graphic file task Reply with quote

Hi James,

Thanks for the tip. Yes, I am aware of that site and have been working on
some demos that came from there.

Andy

"James Brown" <Jim (AT) SETI (DOT) Net> wrote in message
news:PCPXg.1713$zy2.1330 (AT) tornado (DOT) socal.rr.com...
Quote:
Take a look at this site:
http://www.efg2.com/Lab/

He has a lot of Delphi graphic code with source. Good reference.
Regards.. Jim
"Andy" <nospam (AT) prizm (DOT) com> wrote in message
news:452f4d67$1 (AT) newsgroups (DOT) borland.com...
I have an equipment that produces a 24-bit image of a gray background and
black or white pixels. Since it is 24-bit, it has many shades of gray,
black
and white. I was told to do the following:

1. ability to change the colors gray, black or white to a user-defined
color
2. ability to include/exclude the colors independently so as to show the
gray, black or white alone

In order to do this, I think I need to reduce the colors so there are not
too many shades of gray, black or white but a distinct shade of either
gray,
black or white. How do I do this? Once that is accomplished, how do I
locate
the range of colors to do the rest, like changing the color or
include/exclude certain colors?

If I need any third-party components to do this easily with examples, I
would be interested too. I thank you in advance for any help.

Andy





Back to top
helmut
Guest





PostPosted: Sat Oct 14, 2006 8:11 am    Post subject: Re: Help with graphic file task Reply with quote

have a look at graphics32 library..its fast and has simple pixel commands so
you dont have to mess around with that scanline stuff.
http://graphics32.org/wiki/pub/page/Main/HomePage
its free too.

"Andy" <nospam (AT) prizm (DOT) com> wrote in message
news:45301081 (AT) newsgroups (DOT) borland.com...
Quote:
Hi Peter,

Thanks for taking the time to respond.

Sorry for the ignorance on this. I will try to load it into a TBitmap and
muck
around the scanlines property. Do I then try to look at each pixel in the
scanlines
and change the color from there?

Thanks again.

Andy

"Peter Below (TeamB)" <none> wrote in message
news:xn0esfhaz1j6ws001 (AT) newsgroups (DOT) borland.com...
Andy wrote:

I have an equipment that produces a 24-bit image of a gray background
and black or white pixels. Since it is 24-bit, it has many shades of
gray, black and white.

Black and white do not have shades, they are *defined* as the colors
with no or all bits set in the RGB color space. Gray in this color
space is any color that has equal amounts of red, blue, gree set, so
there are only 253 shades of gray possible in this color space,
strictly speaking (plus black and white).

I was told to do the following:

1. ability to change the colors gray, black or white to a
user-defined color 2. ability to include/exclude the colors
independently so as to show the gray, black or white alone

Alone on what? There has to be a background color.

If you can get your image data into a TBitmap, look at the Scanlines
property. It gives you direct access to the pixel data.


--
Peter Below (TeamB)
Don't be a vampire (http://slash7.com/pages/vampires),
use the newsgroup archives :
http://www.tamaracka.com/search.htm
http://groups.google.com
http://www.prolix.be

Back to top
Peter Below (TeamB)
Guest





PostPosted: Sat Oct 14, 2006 6:17 pm    Post subject: Re: Help with graphic file task Reply with quote

Andy wrote:

Quote:
Hi Peter,

Thanks for taking the time to respond.

Sorry for the ignorance on this. I will try to load it into a TBitmap
and muck around the scanlines property. Do I then try to look at each
pixel in the scanlines and change the color from there?

Yes, that is the most direct and usually also the fastest way to
manipulate the pixels of a bitmap. Note that the format of the pixel
data depends on the PixelFormat of the TBitmap. For pf24bit format each
pixel would take 3 consecutive bytes of data, holding a RGBTRIPLE
record.



--
Peter Below (TeamB)
Don't be a vampire (http://slash7.com/pages/vampires),
use the newsgroup archives :
http://www.tamaracka.com/search.htm
http://groups.google.com
http://www.prolix.be
Back to top
Mat Ballard
Guest





PostPosted: Mon Oct 16, 2006 4:17 am    Post subject: Re: Help with graphic file task Reply with quote

Andy wrote:
Quote:
I have an equipment that produces a 24-bit image of a gray background and
black or white pixels. Since it is 24-bit, it has many shades of gray, black
and white.

It has N shades, where N <= 256. Even in a 24-bit color image, you can only have
up to 256 shades of gray.

Ergo, you can reduce it to an 8-bit grayscale which is exactly the same, with a
palette of 256 shades of gray.

To do this, download Anders Melander's TGifImage. A recent version can be found at:

http://www.tolderlund.eu/delphi/gifimaged7e.zip

To create a 8-bit grayscale from 24-bit "color" use the function:

GrayBitmap := GIFImage.ReduceColors(SourceBMP, rmGrayScale, dmNearest, 0, 0);

Note that you eventually have to:

GrayBitmap.Free;

Quote:
I was told to do the following:

1. ability to change the colors gray, black or white to a user-defined color
2. ability to include/exclude the colors independently so as to show the
gray, black or white alone

You need to play with the Colortable:

type
TRGBQuad = // pf32pixel
PACKED RECORD
rgbBlue : BYTE;
rgbGreen: BYTE;
rgbRed : BYTE;
rgbReserved: Byte;
END;
var
ColorTable: array [0..255] of TRGBQuad;
begin
GetDIBColorTable(GrayBitmap.Canvas.Handle, 0, 256, ColorTable);
{play around with colors defined in the in ColorTable, then:}
SetDIBColorTable(GrayBitmap.Canvas.Handle, 0, 256, ColorTable);
{display the result:}
MyImage.Picture.Assign(GrayBitmap);
end;



cheers,


Mat
Back to top
Andy
Guest





PostPosted: Wed Oct 18, 2006 1:33 pm    Post subject: Re: Help with graphic file task Reply with quote

Hi Helmut,

I will definitely take a look at graphics32. Thanks so much for the tip.

Andy

"helmut" <helmut1000 (AT) gmail (DOT) com> wrote in message
news:45308834 (AT) newsgroups (DOT) borland.com...
Quote:
have a look at graphics32 library..its fast and has simple pixel commands
so you dont have to mess around with that scanline stuff.
http://graphics32.org/wiki/pub/page/Main/HomePage
its free too.

"Andy" <nospam (AT) prizm (DOT) com> wrote in message
news:45301081 (AT) newsgroups (DOT) borland.com...
Hi Peter,

Thanks for taking the time to respond.

Sorry for the ignorance on this. I will try to load it into a TBitmap and
muck
around the scanlines property. Do I then try to look at each pixel in the
scanlines
and change the color from there?

Thanks again.

Andy

"Peter Below (TeamB)" <none> wrote in message
news:xn0esfhaz1j6ws001 (AT) newsgroups (DOT) borland.com...
Andy wrote:

I have an equipment that produces a 24-bit image of a gray background
and black or white pixels. Since it is 24-bit, it has many shades of
gray, black and white.

Black and white do not have shades, they are *defined* as the colors
with no or all bits set in the RGB color space. Gray in this color
space is any color that has equal amounts of red, blue, gree set, so
there are only 253 shades of gray possible in this color space,
strictly speaking (plus black and white).

I was told to do the following:

1. ability to change the colors gray, black or white to a
user-defined color 2. ability to include/exclude the colors
independently so as to show the gray, black or white alone

Alone on what? There has to be a background color.

If you can get your image data into a TBitmap, look at the Scanlines
property. It gives you direct access to the pixel data.


--
Peter Below (TeamB)
Don't be a vampire (http://slash7.com/pages/vampires),
use the newsgroup archives :
http://www.tamaracka.com/search.htm
http://groups.google.com
http://www.prolix.be



Back to top
Andy
Guest





PostPosted: Wed Oct 18, 2006 1:34 pm    Post subject: Re: Help with graphic file task Reply with quote

Hi Peter,

Thanks for the tip. Graphics subject is definitely a handful.

Andy

"Peter Below (TeamB)" <none> wrote in message
news:xn0esgo3f8r2ds000 (AT) newsgroups (DOT) borland.com...
Quote:
Andy wrote:

Hi Peter,

Thanks for taking the time to respond.

Sorry for the ignorance on this. I will try to load it into a TBitmap
and muck around the scanlines property. Do I then try to look at each
pixel in the scanlines and change the color from there?

Yes, that is the most direct and usually also the fastest way to
manipulate the pixels of a bitmap. Note that the format of the pixel
data depends on the PixelFormat of the TBitmap. For pf24bit format each
pixel would take 3 consecutive bytes of data, holding a RGBTRIPLE
record.



--
Peter Below (TeamB)
Don't be a vampire (http://slash7.com/pages/vampires),
use the newsgroup archives :
http://www.tamaracka.com/search.htm
http://groups.google.com
http://www.prolix.be
Back to top
Andy
Guest





PostPosted: Wed Oct 18, 2006 1:35 pm    Post subject: Re: Help with graphic file task Reply with quote

Hi Mat,

Thanks so much for the tip. It was very helpful. I will try to use the
TGifImage and
see what I can come up with.

Thanks again.

Andy

"Mat Ballard" <mat (AT) chemwares (DOT) com> wrote in message
news:4532c181$1 (AT) newsgroups (DOT) borland.com...
Quote:
Andy wrote:
I have an equipment that produces a 24-bit image of a gray background and
black or white pixels. Since it is 24-bit, it has many shades of gray,
black
and white.

It has N shades, where N <= 256. Even in a 24-bit color image, you can
only have
up to 256 shades of gray.

Ergo, you can reduce it to an 8-bit grayscale which is exactly the same,
with a
palette of 256 shades of gray.

To do this, download Anders Melander's TGifImage. A recent version can be
found at:

http://www.tolderlund.eu/delphi/gifimaged7e.zip

To create a 8-bit grayscale from 24-bit "color" use the function:

GrayBitmap := GIFImage.ReduceColors(SourceBMP, rmGrayScale, dmNearest, 0,
0);

Note that you eventually have to:

GrayBitmap.Free;

I was told to do the following:

1. ability to change the colors gray, black or white to a user-defined
color
2. ability to include/exclude the colors independently so as to show the
gray, black or white alone

You need to play with the Colortable:

type
TRGBQuad = // pf32pixel
PACKED RECORD
rgbBlue : BYTE;
rgbGreen: BYTE;
rgbRed : BYTE;
rgbReserved: Byte;
END;
var
ColorTable: array [0..255] of TRGBQuad;
begin
GetDIBColorTable(GrayBitmap.Canvas.Handle, 0, 256, ColorTable);
{play around with colors defined in the in ColorTable, then:}
SetDIBColorTable(GrayBitmap.Canvas.Handle, 0, 256, ColorTable);
{display the result:}
MyImage.Picture.Assign(GrayBitmap);
end;



cheers,


Mat
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Graphics All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.