|
Gif images use an indexed pixel format. You just cannot try to lock bits if the pixel format you give does not match the one of the image.
|
|
|
|
|
Not true.
From the docs: "The pixel format of the temporary buffer does not have to be the same as the pixel format of this Bitmap object. "
I just tried LockBits on a 8bppIndexed GIF and it worked fine getting the bits as 24bppRGB.
Of course that's not going to work out for the processing the OP wants to do on the pixels
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Maybe you are right, I have never tried to lock bits using a different pixel format than the one defined on the bitmap. Also on the docs you can find this:
"passing the incorrect pixel format for a bitmap will throw an System.ArgumentException", here is the page[^].
Mark Salsbery wrote: Of course that's not going to work out for the processing the OP wants to do on
the pixels
Agree... Actually, it would be good to know what he wants to do.
|
|
|
|
|
I have a desktop application where user can enter a virtual directory path (like http://localhost/MySite, or http://MyMachine/MySite). The path will always be local (both virtual and physical directories located on that machine itself). I should then open "MySite" in a browser, but before that I need to fetch some settings from its web.config file. For that I should know the physical location of web.config file (which is the root of "MySite") so that I can open it.
So the question is: how do I get the physical location of "MySite"? Or is there any other approach to what I want to achieve? Please remember, I have a Winform application which has nothing to do with the site "MySite", it just gets its URL through an editbox.
I am new to .Net, so please forgive any stupidity.
It's better to know some of the questions than all of the answers.
Pravin.
|
|
|
|
|
I don't think you can, and this is why: your local web server somehow knows where the root of the local web is, it is like an application setting to it. Example: I am using XAMPP (=Apache) to serve a local PHP-based web site, it holds its root location deep inside a configuration file called "httpd.conf"; I am also using another web server serving an ASP.NET-based web site, it uses a different web root, stored in a different way. How could an application external to all these web servers know where to look for your web root(s)?
Maybe this would work for you: organize an application setting "webroot" for your WinForm, initially "webroot" is empty. Have your app obtain its "webroot" from its setting, when getting a value, just use it; when getting no value, ask the user to locate the web root, and update the setting. That is harassing the user only once (and causing a major problem when you decide to move the web root, unless you also provide a button "Update Web Root Location" which basically empties "webroot".
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Thanks for the answer, Luc. I already have this option of asking the user for webroot, storing them and later showing them in a drop-down to let him choose (or type a new one). I just wanted to remove this harassment by making my app a little more intelligent.
All my users will be on Windows, using IIS 7, if that gives you any more ideas.
It's better to know some of the questions than all of the answers.
Pravin.
|
|
|
|
|
PravinSingh wrote: any more ideas
No, not really. A web server should obviously know, but also not reveal, where the web root is. As I explained, you don't need to ask the user each time, once is enough (unless it changes). And that once could probably be at installation time of your app.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Since your site will always run on IIS, you can make the site an ASP.NET app and add a web service to the site that the calling app can call to ask for the information.
That's what you should be doing anyway....client apps shouldn't need direct access to that stuff.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi Respected Seniors,
Kindly let me know one or two examples, How may I subtract / "Diffrence" time.
for example:
string strStudentTime = "10:00";
string strSystemTime = "10:15";
I need difference.
Thank you
(Riaz Bashir)
|
|
|
|
|
You can use Timespan[^] when need any kind of difference between two dates or time.
Regards,
Hiren.
-"I don't know, I don't care, and it doesn't make any difference".
|
|
|
|
|
As Hiren said, look at the TimeSpan class. Specifically, you'll need to read these values in (using TryParse) to a TimeSpan, and then you can get the difference from there.
|
|
|
|
|
You should not hold times, dates, or datetimes in strings; strings here are useful only for showing actual values to human users. Keep them in DateTime types instead, so you have all DateTime operators and methods available, including subtraction, which results in a TimeSpan.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
If it is a 24-hour clock, and the format is fixed as hh:mm, you can do it in a very simple way, without the system classes:
private static int ParseTime(string s) {
return 60*int.Parse(s.Substring(0, 2)) + int.Parse(s.Substring(3));
}
...
var diffInMinutes = ParseTime(strSystemTime) - ParseTime(strSystemTime);
If your code needs to be more robust than that, you should use DateTime to parse your strings, and then use the "-" operator to obtain their difference.
|
|
|
|
|
If you have a time then you should use TimeSpan.
If you have a timestamp then you should use DateTimeOffset (rather than DateTime.)
|
|
|
|
|
private int m_number;
public int My_NUM
{
get{ return m_number;}
set{m_number=value;}
}
----------
public int M_NUM2
{
get;
set;
}
when we can use of second way why we need to use of first way?
Thanks
|
|
|
|
|
The second way internally creates a version that matches the first, so in this simple case there's no need to do the first one. If your logic needs to do more though, then it becomes important to have the first form. The typical case here is where you have a property that needs to raise a PropertyChanged event when the value changes - you have to trigger this logic from the setter, so you need to do this.
|
|
|
|
|
As Pete already said, the second way is a shorthand for what you have in the first way, however the first way is much more powerful as you can add statements to the get and or the set method, maybe checking an input value and throwing an exception when it is unacceptable; maybe recalculating or repainting something (that is what the TextBox.Text setter would do).
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Second way is property declaration in C# 3.0, for C# 2.0 you have to strict with first implementation.
If you want to do some validation in (get) and (set) then second way should not work. Like, on saving (set) a value you would like to check then you have to write validation code in set block.
private int m_number;
public int My_NUM
{
get{ return m_number;}
set{
if (value > 0)
m_number=value;
}
}
Regards
Rushi
|
|
|
|
|
The second form is also called as Auto Property.
|
|
|
|
|
Hi,
I have a datatable which is having 3 rows ,3 columns (min %,max%,default%)
and the values are string type and values are like 2%,5% etc...
now i want to remove percentage(%) in all the values in the table...ie the column values should be 2,5 etc...
Please help me regarding the same..
-- Modified Wednesday, May 11, 2011 2:19 AM
|
|
|
|
|
It is not clear. Could you clarify this problem?
"The worst code you'll come across is code you wrote last year.", wizardzz[ ^]
|
|
|
|
|
I don't know you what actually you want to accomplish, But to just remove % you can loop through each rows and columns and use following.
table.Rows[i][j].ToString().Replace("%", String.Empty);
Regards,
Hiren.
-"I don't know, I don't care, and it doesn't make any difference".
|
|
|
|
|
Here are two suggestions:
1.
Each column of a DGV has a default style which you can alter; here is a typical statement doing that:
dgvArticles.Columns[DGVA_COL_BOOKMARKS].DefaultCellStyle.Format="#,###";
This would set the style of all data cells in one column, it probably is what you want.
For numbers you can specify different styles for positive, negative and zero values.
2.
Every time a cell is going to be recalculated for later painting, a DGV cell fires its CellFormatting event. You can assign a handler, that determines the style to be used at run-time, and this for individual cells. Here is another (partial) example:
private void dgvUsers_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) {
if (e.RowIndex...) {
if (e.ColumnIndex...) {
e.CellStyle.BackColor=Color.Gold;
}
}
}
FYI: both examples were inspired by actual code inside my "CP Vanity" article.
BTW: the above is NOT changing the value in the cells, it is only changing the way the cell content looks.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Hi ,
How can we make sure that which part causes error in MStest failure. ?.Please let me know.
With Thanks regards.
|
|
|
|
|
Could you please be descriptive about the problem.
"The worst code you'll come across is code you wrote last year.", wizardzz[ ^]
|
|
|
|