|
|
|
start date: Wed, 25 Jul 2007 09:23:56 -0400,
posted on: microsoft.public.dotnet.framework.drawing
back
| Thread Index |
|
1
active
|
|
2
active
|
|
3
Bob Powell [MVP]
|
|
4
active
|
|
5
active
|
|
6
Bob Powell [MVP]
|
|
7
active
|
|
8
active
|
question about Powell's "Creating Transparent GIF Images"
Why couldn't the palette of the saved bitmap be revised and re-inserted back
into that bitmap.
Rather then the time consuming coping of all that bitmap's data to a new
bitmap?
I'm sure knowing that is important to knowing how to work with indexed
files.
Thank
Date:Wed, 25 Jul 2007 09:23:56 -0400
Author:
|
Re: question about Powell's "Creating Transparent GIF Images"
I should have said more.
I have read Powell's comment that makes it sound like (to me anyway) there
are two palettes, one for display and one used while saving.
But the palette in the temporary bitmap (bm) is changed. If that can be
done, why can't the palette in the saved bitmap be changed?
Or why not :
're-insert the palette
_gifImage.Palette=ncp
and be done?
I think there is much to learn from that code.
Thanks
" active" wrote in message
news:O9UtO8rzHHA.4916@TK2MSFTNGP03.phx.gbl...
> Why couldn't the palette of the saved bitmap be revised and re-inserted
> back into that bitmap.
>
> Rather then the time consuming coping of all that bitmap's data to a new
> bitmap?
>
>
> I'm sure knowing that is important to knowing how to work with indexed
> files.
>
>
>
> Thank
>
>
>
Date:Wed, 25 Jul 2007 09:35:52 -0400
Author:
|
Re: question about Powell's "Creating Transparent GIF Images"
Palettes do not necessarily contain colours that make logical sense. A
palette may have predominance of blues or greens for example if the
histogram of the image dictates their relative weights as being important.
The contents of a palette won't be in any specific order either, so the
palette produced for a given image will almost certainly not be of any
use on another image.
The only way to ensure that all images are equal (equally bad that is)
is to provide the same palette for all images and the same indexes for
each colour in the palette so that the colour of the pixel itself can be
used to determine the index in the palette. This is how the GDI+ spread
palette works.
All images that originate from basic GDI+ codecs use this palette but it
is just about guaranteed that ANY other program will create a custom
palette for the image simply because this is how GIF was supposed to work.
--
Bob Powell [MVP]
Visual C#, System.Drawing
Ramuseco Limited .NET consulting
http://www.ramuseco.com
Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm
Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm
All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
active wrote:
> I should have said more.
> I have read Powell's comment that makes it sound like (to me anyway) there
> are two palettes, one for display and one used while saving.
>
>
> But the palette in the temporary bitmap (bm) is changed. If that can be
> done, why can't the palette in the saved bitmap be changed?
>
> Or why not :
> 're-insert the palette
> _gifImage.Palette=ncp
>
> and be done?
>
> I think there is much to learn from that code.
>
>
> Thanks
>
>
> " active" wrote in message
> news:O9UtO8rzHHA.4916@TK2MSFTNGP03.phx.gbl...
>> Why couldn't the palette of the saved bitmap be revised and re-inserted
>> back into that bitmap.
>>
>> Rather then the time consuming coping of all that bitmap's data to a new
>> bitmap?
>>
>>
>> I'm sure knowing that is important to knowing how to work with indexed
>> files.
>>
>>
>>
>> Thank
>>
>>
>>
>
>
Date:Thu, 26 Jul 2007 20:52:26 +0200
Author:
|
Re: question about Powell's "Creating Transparent GIF Images"
I think the thing I was missing is that if I make a new bitmap similar to
one I have and draw the one I have on the new one, even though the colors
and image are exactly the same, the locations in the palette will probable
differ.
I was focused on the fact that they had the same colors so thought the same
palette should work.
(Actually it now seems to me that even the colors in the palette could be
different)
Thanks for helping
"Bob Powell [MVP]" wrote in message
news:uVtSWX7zHHA.5644@TK2MSFTNGP05.phx.gbl...
> Palettes do not necessarily contain colours that make logical sense. A
> palette may have predominance of blues or greens for example if the
> histogram of the image dictates their relative weights as being important.
>
> The contents of a palette won't be in any specific order either, so the
> palette produced for a given image will almost certainly not be of any use
> on another image.
>
> The only way to ensure that all images are equal (equally bad that is) is
> to provide the same palette for all images and the same indexes for each
> colour in the palette so that the colour of the pixel itself can be used
> to determine the index in the palette. This is how the GDI+ spread palette
> works.
>
> All images that originate from basic GDI+ codecs use this palette but it
> is just about guaranteed that ANY other program will create a custom
> palette for the image simply because this is how GIF was supposed to work.
>
> --
> Bob Powell [MVP]
> Visual C#, System.Drawing
>
> Ramuseco Limited .NET consulting
> http://www.ramuseco.com
>
> Find great Windows Forms articles in Windows Forms Tips and Tricks
> http://www.bobpowell.net/tipstricks.htm
>
> Answer those GDI+ questions with the GDI+ FAQ
> http://www.bobpowell.net/faqmain.htm
>
> All new articles provide code in C# and VB.NET.
> Subscribe to the RSS feeds provided and never miss a new article.
>
>
>
>
>
> active wrote:
>> I should have said more.
>> I have read Powell's comment that makes it sound like (to me anyway)
>> there are two palettes, one for display and one used while saving.
>>
>>
>> But the palette in the temporary bitmap (bm) is changed. If that can be
>> done, why can't the palette in the saved bitmap be changed?
>>
>> Or why not :
>> 're-insert the palette
>> _gifImage.Palette=ncp
>>
>> and be done?
>>
>> I think there is much to learn from that code.
>>
>>
>> Thanks
>>
>>
>> " active" wrote in message
>> news:O9UtO8rzHHA.4916@TK2MSFTNGP03.phx.gbl...
>>> Why couldn't the palette of the saved bitmap be revised and re-inserted
>>> back into that bitmap.
>>>
>>> Rather then the time consuming coping of all that bitmap's data to a new
>>> bitmap?
>>>
>>>
>>> I'm sure knowing that is important to knowing how to work with indexed
>>> files.
>>>
>>>
>>>
>>> Thank
>>>
>>>
>>>
>>
Date:Thu, 26 Jul 2007 15:17:23 -0400
Author:
|
Re: question about Powell's "Creating Transparent GIF Images"
I still confused about something!
In your Creating Transparent GIF Images why couldn't get the palette from
the bitmap, revise it and then insert it back?
thanks
" active" wrote in message
news:esGNZm7zHHA.4656@TK2MSFTNGP04.phx.gbl...
>I think the thing I was missing is that if I make a new bitmap similar to
>one I have and draw the one I have on the new one, even though the colors
>and image are exactly the same, the locations in the palette will probable
>differ.
>
> I was focused on the fact that they had the same colors so thought the
> same palette should work.
>
> (Actually it now seems to me that even the colors in the palette could be
> different)
>
> Thanks for helping
>
>
> "Bob Powell [MVP]" wrote in message
> news:uVtSWX7zHHA.5644@TK2MSFTNGP05.phx.gbl...
>> Palettes do not necessarily contain colours that make logical sense. A
>> palette may have predominance of blues or greens for example if the
>> histogram of the image dictates their relative weights as being
>> important.
>>
>> The contents of a palette won't be in any specific order either, so the
>> palette produced for a given image will almost certainly not be of any
>> use on another image.
>>
>> The only way to ensure that all images are equal (equally bad that is) is
>> to provide the same palette for all images and the same indexes for each
>> colour in the palette so that the colour of the pixel itself can be used
>> to determine the index in the palette. This is how the GDI+ spread
>> palette works.
>>
>> All images that originate from basic GDI+ codecs use this palette but it
>> is just about guaranteed that ANY other program will create a custom
>> palette for the image simply because this is how GIF was supposed to
>> work.
>>
>> --
>> Bob Powell [MVP]
>> Visual C#, System.Drawing
>>
>> Ramuseco Limited .NET consulting
>> http://www.ramuseco.com
>>
>> Find great Windows Forms articles in Windows Forms Tips and Tricks
>> http://www.bobpowell.net/tipstricks.htm
>>
>> Answer those GDI+ questions with the GDI+ FAQ
>> http://www.bobpowell.net/faqmain.htm
>>
>> All new articles provide code in C# and VB.NET.
>> Subscribe to the RSS feeds provided and never miss a new article.
>>
>>
>>
>>
>>
>> active wrote:
>>> I should have said more.
>>> I have read Powell's comment that makes it sound like (to me anyway)
>>> there are two palettes, one for display and one used while saving.
>>>
>>>
>>> But the palette in the temporary bitmap (bm) is changed. If that can be
>>> done, why can't the palette in the saved bitmap be changed?
>>>
>>> Or why not :
>>> 're-insert the palette
>>> _gifImage.Palette=ncp
>>>
>>> and be done?
>>>
>>> I think there is much to learn from that code.
>>>
>>>
>>> Thanks
>>>
>>>
>>> " active" wrote in message
>>> news:O9UtO8rzHHA.4916@TK2MSFTNGP03.phx.gbl...
>>>> Why couldn't the palette of the saved bitmap be revised and re-inserted
>>>> back into that bitmap.
>>>>
>>>> Rather then the time consuming coping of all that bitmap's data to a
>>>> new bitmap?
>>>>
>>>>
>>>> I'm sure knowing that is important to knowing how to work with indexed
>>>> files.
>>>>
>>>>
>>>>
>>>> Thank
>>>>
>>>>
>>>>
>>>
>
Date:Thu, 26 Jul 2007 15:56:49 -0400
Author:
|
Re: question about Powell's "Creating Transparent GIF Images"
How many ways do you imagine I can explain "No" in a convincing manner??
--
Bob Powell [MVP]
Visual C#, System.Drawing
Ramuseco Limited .NET consulting
http://www.ramuseco.com
Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm
Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm
All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
active wrote:
> I still confused about something!
> In your Creating Transparent GIF Images why couldn't get the palette from
> the bitmap, revise it and then insert it back?
>
> thanks
>
> " active" wrote in message
> news:esGNZm7zHHA.4656@TK2MSFTNGP04.phx.gbl...
>> I think the thing I was missing is that if I make a new bitmap similar to
>> one I have and draw the one I have on the new one, even though the colors
>> and image are exactly the same, the locations in the palette will probable
>> differ.
>>
>> I was focused on the fact that they had the same colors so thought the
>> same palette should work.
>>
>> (Actually it now seems to me that even the colors in the palette could be
>> different)
>>
>> Thanks for helping
>>
>>
>> "Bob Powell [MVP]" wrote in message
>> news:uVtSWX7zHHA.5644@TK2MSFTNGP05.phx.gbl...
>>> Palettes do not necessarily contain colours that make logical sense. A
>>> palette may have predominance of blues or greens for example if the
>>> histogram of the image dictates their relative weights as being
>>> important.
>>>
>>> The contents of a palette won't be in any specific order either, so the
>>> palette produced for a given image will almost certainly not be of any
>>> use on another image.
>>>
>>> The only way to ensure that all images are equal (equally bad that is) is
>>> to provide the same palette for all images and the same indexes for each
>>> colour in the palette so that the colour of the pixel itself can be used
>>> to determine the index in the palette. This is how the GDI+ spread
>>> palette works.
>>>
>>> All images that originate from basic GDI+ codecs use this palette but it
>>> is just about guaranteed that ANY other program will create a custom
>>> palette for the image simply because this is how GIF was supposed to
>>> work.
>>>
>>> --
>>> Bob Powell [MVP]
>>> Visual C#, System.Drawing
>>>
>>> Ramuseco Limited .NET consulting
>>> http://www.ramuseco.com
>>>
>>> Find great Windows Forms articles in Windows Forms Tips and Tricks
>>> http://www.bobpowell.net/tipstricks.htm
>>>
>>> Answer those GDI+ questions with the GDI+ FAQ
>>> http://www.bobpowell.net/faqmain.htm
>>>
>>> All new articles provide code in C# and VB.NET.
>>> Subscribe to the RSS feeds provided and never miss a new article.
>>>
>>>
>>>
>>>
>>>
>>> active wrote:
>>>> I should have said more.
>>>> I have read Powell's comment that makes it sound like (to me anyway)
>>>> there are two palettes, one for display and one used while saving.
>>>>
>>>>
>>>> But the palette in the temporary bitmap (bm) is changed. If that can be
>>>> done, why can't the palette in the saved bitmap be changed?
>>>>
>>>> Or why not :
>>>> 're-insert the palette
>>>> _gifImage.Palette=ncp
>>>>
>>>> and be done?
>>>>
>>>> I think there is much to learn from that code.
>>>>
>>>>
>>>> Thanks
>>>>
>>>>
>>>> " active" wrote in message
>>>> news:O9UtO8rzHHA.4916@TK2MSFTNGP03.phx.gbl...
>>>>> Why couldn't the palette of the saved bitmap be revised and re-inserted
>>>>> back into that bitmap.
>>>>>
>>>>> Rather then the time consuming coping of all that bitmap's data to a
>>>>> new bitmap?
>>>>>
>>>>>
>>>>> I'm sure knowing that is important to knowing how to work with indexed
>>>>> files.
>>>>>
>>>>>
>>>>>
>>>>> Thank
>>>>>
>>>>>
>>>>>
>
>
Date:Thu, 26 Jul 2007 22:58:12 +0200
Author:
|
Re: question about Powell's "Creating Transparent GIF Images"
Oh, I believe you no doubt about that!
It's just that in that case there was no changing of indexes nor colors
(except for the high byte)
Thanks for all the help you've given
"Bob Powell [MVP]" wrote in message
news:e09Tnd8zHHA.4656@TK2MSFTNGP04.phx.gbl...
> How many ways do you imagine I can explain "No" in a convincing manner??
>
> --
> Bob Powell [MVP]
> Visual C#, System.Drawing
>
> Ramuseco Limited .NET consulting
> http://www.ramuseco.com
>
> Find great Windows Forms articles in Windows Forms Tips and Tricks
> http://www.bobpowell.net/tipstricks.htm
>
> Answer those GDI+ questions with the GDI+ FAQ
> http://www.bobpowell.net/faqmain.htm
>
> All new articles provide code in C# and VB.NET.
> Subscribe to the RSS feeds provided and never miss a new article.
>
>
>
>
>
> active wrote:
>> I still confused about something!
>> In your Creating Transparent GIF Images why couldn't get the palette from
>> the bitmap, revise it and then insert it back?
>>
>> thanks
>>
>> " active" wrote in message
>> news:esGNZm7zHHA.4656@TK2MSFTNGP04.phx.gbl...
>>> I think the thing I was missing is that if I make a new bitmap similar
>>> to one I have and draw the one I have on the new one, even though the
>>> colors and image are exactly the same, the locations in the palette will
>>> probable differ.
>>>
>>> I was focused on the fact that they had the same colors so thought the
>>> same palette should work.
>>>
>>> (Actually it now seems to me that even the colors in the palette could
>>> be different)
>>>
>>> Thanks for helping
>>>
>>>
>>> "Bob Powell [MVP]" wrote in message
>>> news:uVtSWX7zHHA.5644@TK2MSFTNGP05.phx.gbl...
>>>> Palettes do not necessarily contain colours that make logical sense. A
>>>> palette may have predominance of blues or greens for example if the
>>>> histogram of the image dictates their relative weights as being
>>>> important.
>>>>
>>>> The contents of a palette won't be in any specific order either, so the
>>>> palette produced for a given image will almost certainly not be of any
>>>> use on another image.
>>>>
>>>> The only way to ensure that all images are equal (equally bad that is)
>>>> is to provide the same palette for all images and the same indexes for
>>>> each colour in the palette so that the colour of the pixel itself can
>>>> be used to determine the index in the palette. This is how the GDI+
>>>> spread palette works.
>>>>
>>>> All images that originate from basic GDI+ codecs use this palette but
>>>> it is just about guaranteed that ANY other program will create a custom
>>>> palette for the image simply because this is how GIF was supposed to
>>>> work.
>>>>
>>>> --
>>>> Bob Powell [MVP]
>>>> Visual C#, System.Drawing
>>>>
>>>> Ramuseco Limited .NET consulting
>>>> http://www.ramuseco.com
>>>>
>>>> Find great Windows Forms articles in Windows Forms Tips and Tricks
>>>> http://www.bobpowell.net/tipstricks.htm
>>>>
>>>> Answer those GDI+ questions with the GDI+ FAQ
>>>> http://www.bobpowell.net/faqmain.htm
>>>>
>>>> All new articles provide code in C# and VB.NET.
>>>> Subscribe to the RSS feeds provided and never miss a new article.
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> active wrote:
>>>>> I should have said more.
>>>>> I have read Powell's comment that makes it sound like (to me anyway)
>>>>> there are two palettes, one for display and one used while saving.
>>>>>
>>>>>
>>>>> But the palette in the temporary bitmap (bm) is changed. If that can
>>>>> be done, why can't the palette in the saved bitmap be changed?
>>>>>
>>>>> Or why not :
>>>>> 're-insert the palette
>>>>> _gifImage.Palette=ncp
>>>>>
>>>>> and be done?
>>>>>
>>>>> I think there is much to learn from that code.
>>>>>
>>>>>
>>>>> Thanks
>>>>>
>>>>>
>>>>> " active" wrote in message
>>>>> news:O9UtO8rzHHA.4916@TK2MSFTNGP03.phx.gbl...
>>>>>> Why couldn't the palette of the saved bitmap be revised and
>>>>>> re-inserted back into that bitmap.
>>>>>>
>>>>>> Rather then the time consuming coping of all that bitmap's data to a
>>>>>> new bitmap?
>>>>>>
>>>>>>
>>>>>> I'm sure knowing that is important to knowing how to work with
>>>>>> indexed files.
>>>>>>
>>>>>>
>>>>>>
>>>>>> Thank
>>>>>>
>>>>>>
>>>>>>
>>
Date:Thu, 26 Jul 2007 22:25:51 -0400
Author:
|
Re: question about Powell's "Creating Transparent GIF Images"
Please prove me wrong.
I've been looking at this and can't find anything I'm mistaking (but
wouldn't be surprised if someone else does)
I simply reinsert the modified palette and the displayed 8-bit image changes
as expected.
Thanks
'Create a new 8 bit per pixelbitmap
Dim Bm As New Bitmap(SplitContainer3.Panel1.BackgroundImage.Width,
SplitContainer3.Panel1.BackgroundImage.Height,
PixelFormat.Format8bppIndexed)
'get it's palette
Dim NCP As ColorPalette = Bm.Palette
'copy and modify all the entries from the old palette
For n As Integer = 0 To NCP.Entries.Length - 1
If n >= SplitContainer3.Panel1.BackgroundImage.Palette.Entries.Length Then
NCP.Entries(n) = Color.Black
Else
'ncp.Entries(n) = Color.FromArgb(255, GifCP.Entries(n))
'NCP.Entries(n) = Color.FromArgb(255,
SplitContainer3.Panel1.BackgroundImage.Palette.Entries(n).G,
SplitContainer3.Panel1.BackgroundImage.Palette.Entries(n).B,
SplitContainer3.Panel1.BackgroundImage.Palette.Entries(n).R)
'NCP.Entries(n) = Color.FromArgb(255, 0,
SplitContainer3.Panel1.BackgroundImage.Palette.Entries(n).G, 0)
NCP.Entries(n) = Color.FromArgb(255,
SplitContainer3.Panel1.BackgroundImage.Palette.Entries(n).R, 0, 0)
End If
Next n
're-insert the palette
SplitContainer3.Panel1.BackgroundImage.Palette = NCP
'SplitContainer3.Panel1.BackgroundImage is 8-bit indexed
Date:Fri, 27 Jul 2007 18:54:51 -0400
Author:
|
|
|