|
I am working with large bitmaps (in the range of 5000x5000 pixels) and found no support for loading the image with gray scale. The only supported 4 and 8 bit format is colour, what I found online was the 16 bit format doesn't work. Using a gray scale conversion after the fact was very time consuming. In the end I changed the palette of the 8 bit format using the following code
ColorPalette pal = segyBMP.Palette;
int j = 255;
for (int i = 0; i < pal.Entries.Length; i++)
{
pal.Entries[i] = Color.FromArgb(j, j, j);
j--;
}
segyBMP.Palette = pal;
(The decrementing j is to reverse the black/white - saves me else where is the code.)
Does anyone know if there is a gray scale palette already in the system so I wouldn't have to make my own? Or a better way to handle the gray scale issue? I don't want/need colour and size does matter. I want to keep it to 8 or maybe 4 bit format.
Jim
-- modified at 13:20 Friday 2nd February, 2007
|
|
|
|
|
AFAIK there are no ready-made palettes whatsoever, and I cannot imagine a simpler
way to construct the one you are using.
I trust you use images with PixelFormat=Format8bppIndexed.
Luc Pattyn
|
|
|
|
|
jimwawar wrote: The only supported 4 and 8 bit format is colour, what I found online was the 16 bit format doesn't work.
Interesting. The 16 bit format is interesting, because it stores partial color values. However, it certainly 'works'. 4 and 8 bit have palettes, anything higher, doesn't. My image processing articles show how to convert 24/32 bit to greyscale, making it work with 16 bit is pretty easy.
jimwawar wrote: Does anyone know if there is a gray scale palette already in the system so I wouldn't have to make my own?
No, a palette is just a palette.
jimwawar wrote: I don't want/need colour and size does matter. I want to keep it to 8 or maybe 4 bit format.
I'd be inclined to convert to 24 bit, convert to gray with a color matrix, and convert back. I'm not sure which would be faster, but that seems less error prone.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hi ,
I am using a property grid to show some controls property and dynamically set them.I want to remove some property or customized some choosed property .How can I do this.Please help me.It is urgent.
thanks in Advance
Sandy
|
|
|
|
|
If it's urgent, then learn to use google. It is not good form to say that something is urgent, because while it's urgent for you it doesn't affect me one way or the other. Why should I be inconvenienced by your lack of planning?
As a hint, take a look at BrowsableAttribute.
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Hi, all!
I have a following problem, and i can't find a right solution.
Description:
There is a COM server written on C++ and it works through IDispatch and it does't have a TYPELIB. And from another side there is a COM client developed on C#. Through LATE BINDING it uses a COM server
and COM server sends different events to client, but i can't implement COM event handling mechanism.
Please, anybody can help me?!
Thanks in advance!
|
|
|
|
|
how to insert undeletable image in word document
Please h
Arun Kr
|
|
|
|
|
OK. First of all, navigate to the top right hand corner of this web page. Do you see the text highlighted in red? That says .Net Framework and not Microsoft Office. You can probably guess where I'm going with this.
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Hello All,
I have a client app which is in .NET 1.0 and i have to work on a webservice, i was
wondering if i can write the webservice in 2.0. In this case, will the WSE 3.0 for the
webservice and WSE 2.0 for the client app in .NET 1.0 still work. Or it won't.
Help Me !!
Ankit Sharma
|
|
|
|
|
I'm writing a database class , I need to use a table variable from within .Net (C#), but it always gives an SQLException saying "Must declare the table variable '@Par1'."
1. I declared an SQLParameter object
2. I added the object to the 'Parameters' collection of the command
How can I solve this
|
|
|
|
|
What's the 'Exit For' equivalent in C#?
|
|
|
|
|
|
|
Most times when you use this it indicates that you have used the wrong construct. If you are issuing a break then this shows that you have reached a terminating condition.
If you need to drop out of a loop early, this would indicate that you should be using something like a while loop instead. See the following:
for (int i = 0; i < 10 ; i++)
{
if (i == 2) break;
}
Contrast this with:
int i = 0;
while (i++ != 2)
{
}
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Pete O'Hanlon wrote: If you need to drop out of a loop early, this would indicate that you should be using something like a while loop instead.
Or a different for expression
Node n = null;
NodeList list = doc.selectNodes("*");
for(int j=0, null == n && j < list.Length, j++)
{
if( ???)
n = list[j];
}
led mike
|
|
|
|
|
Ya, Ya, we all know the theory; but break is more handier
|
|
|
|
|
Handy doesn't make it right. Just lazy. If you take shortcuts here, where else do you take shortcuts? Whenever I see something like this, it sets the alarm bells ringing that there are problems with the design.
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
And if it's due to an exceptional state, it may be more expressive. But certainly use it with caution.
|
|
|
|
|
Hi guys,
Does anyone know how to deploy the MMC Snapin project ?
Thanks,
Glen
|
|
|
|
|
In my application, I have a DataGrid that is used to display search results from a query into a Firebird SQL database. The DataGrid is not directly connected to the DB, but instead I perform my query and store the results in a std::vector, perform some more work on it, then copy the final results into an ArrayList that the DataGrid is connected to.
So, when I do a search, it goes like this:
search_results_list->Clear();
tr = db_conn->BeginTransaction();
typedef vector<int>::const_iterator CIter;
for (CIter it = run_ids.begin(); it != run_ids.end(); ++it) {
search_results_list->Add(disp);
}
tr->Commit();
datagrid_search_results->DataSource = 0;
datagrid_search_results->DataSource = search_results_list; This works fine the first time, however I am having the following problem. If I click on a row, then subsequently perform another search that makes the row disappear, I get an IndexOutOfRange exception:
************** Exception Text **************
System.IndexOutOfRangeException: Index was outside the bounds of the array.
at System.Windows.Forms.DataGrid.Edit(String instantText)
at System.Windows.Forms.DataGrid.Edit()
at System.Windows.Forms.DataGrid.OnEnter(EventArgs e)
at System.Windows.Forms.Control.NotifyEnter()
at System.Windows.Forms.ContainerControl.UpdateFocusedControl()
However, my DataGrid has set the ReadOnly property to true . In my other DataGrid that is used for a different purpose, I was able to solve it by setting the CurrentSelectedRow property to 0 before removing the elements, but this does not work in this situation.
I am not sure if it is related to this, but the only event I am handling for this DataGrid is the MouseUp event, in order to get it to select the entire row when a cell is clicked:
System::Void datagrid_MouseUp(System::Object* sender, System::Windows::Forms::MouseEventArgs* e)
{
using System::Drawing::Point;
using System::Windows::Forms::DataGrid;
using System::Windows::Forms::DataGridCell;
Point pt = Point(e->X, e->Y);
DataGrid* datagrid = __try_cast<DataGrid*>(sender);
DataGrid::HitTestInfo* hti = datagrid->HitTest(pt);
if (hti->Type == DataGrid::HitTestType::Cell) {
datagrid->CurrentCell = DataGridCell(hti->Row, hti->Column);
datagrid->Select(hti->Row);
}
}
--
Marcus Kwok
|
|
|
|
|
ricecake wrote:
datagrid_search_results->DataSource = 0;
datagrid_search_results->DataSource = search_results_list;
So, the solution was to refresh the currency manager after resetting the data source by adding the following two lines:
CurrencyManager* cm = __try_cast<CurrencyManager*>(BindingContext->Item[search_results_list]);
cm->Refresh();
--
Marcus Kwok
|
|
|
|
|
i want to add combobox editor to the extended property(using iextenderprovider) and want to populate the property in the coding intelliscence?
please help me.
thanks.
nilesh kolnoorkar.
|
|
|
|
|
Hi all,
i want to know how to get asp.net 2005 automatically change build number for the project "each time i build it", also i want to know why .net 2005 doesn't have a bin directory containing dll files and how can i manage this issue too.
Thank you
|
|
|
|
|
Search the articles here on CP. There's one that I use.
|
|
|
|
|
Hi All,
What's the equivalent of CScrollView in .NET? I'm looking for something to let me draw large vector diagrams in a scrollable, zoomable view, then print them either on multiple pages or scale-to-fit, and nothing seems to fit the bill.
Any suggestions gratefully received!
|
|
|
|