|
|
i dont think its useful for me but anyway thanks for your helpful replies
a from me
Becoming Programmer...
|
|
|
|
|
Welcome my friend , i am here to share the little bit of knowledge i possess.
Regards,
Adeel
Do rate the reply, if it helps or even if it doesnot, because it helps the members to know, what solved the issue. Thanks.
|
|
|
|
|
hi
i had date in he form of ddmmyy and it is dispalyed as 141107 but i want it to be in the form of 14-11-07
Regards
padma
padma
|
|
|
|
|
So change the display format. How are you rendering it now ? DateTime never renders like that, AFAIK.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
are you using DateTimePicker? if yes
then change it "Format" property to 'Custom'
and in "CustomFormat" property enter your format like "dd-MM-yy"
hope this will help
Becoming Programmer...
|
|
|
|
|
U r fetching from db or selecting date from datepicker?
Cheers
Bino
www.codepal.co.nr
|
|
|
|
|
Hi Padma,
Just test using DateTime.Now.ToString("d"); there are formats avaibale just check by .ToString("m");("y") like that...
|
|
|
|
|
I am attempting to write my own flood fill algorithm, but it is proving to be pretty slow. I am wondering if anyone has an idea on how I can improve performance. Currently, I am using the 4-way non-recursive scanline algorithm, based on a Queue<Point>. I am using the WinAPI methods CreateCompatibleDC, GetPixel, SetPixel, and BitBlt. I have a feeling that if I can copy the bitmap to a byte array, then modify that array directly, then return the array to the bitmap, I can get better performance. Does anyone know how to do this, or have any other ideas as to how I can improve the following code? I copied my code below for examination (note that all the colors I am filling are gray, so R=G=B all the time, if it is a valid fill). Thanks,
private static int ToRGB(Color col) {
return (col.B << 16 | col.G << 8 | col.R);
}
private static bool AreEqual(ref int known, int other) {
if (known == other)
return true;
if ((other & 0xFF) != (other >> 8 & 0xFF) ||
(other & 0xFF) != (other >> 16 & 0xFF) ||
(other & 0xFF) < (known & 0xFF) - 2 ||
(other & 0xFF) > (known & 0xFF) + 2)
return false;
known = other;
return true;
}
private static bool FloodFill(Bitmap img, Point loc, Color fillColor) {
Graphics g = null;
IntPtr hdc1 = IntPtr.Zero, hdc2 = IntPtr.Zero;
try {
g = Graphics.FromImage(img);
hdc1 = g.GetHdc();
Color temp = ((Bitmap)img).GetPixel(loc.X, loc.Y);
hdc2 = WinAPI.CreateCompatibleDC(hdc1);
WinAPI.SelectObject(hdc2, img.GetHbitmap());
int oldColor = WinAPI.GetPixel(hdc2, loc.X, loc.Y);
if ((oldColor & 0xFF) != (oldColor >> 8 & 0xFF) ||
(oldColor & 0xFF) != (oldColor >> 16 & 0xFF))
return false;
Queue<Point> pixels = new Queue<Point>(128);
pixels.Enqueue(loc);
int x, y, newColor = ToRGB(fillColor);
bool spanL, spanR;
do {
loc = pixels.Dequeue();
x = loc.X;
y = loc.Y;
oldColor = WinAPI.GetPixel(hdc2, x, y);
while (y > 0) {
if (!AreEqual(ref oldColor, WinAPI.GetPixel(hdc2, x, --y))) {
++y;
break;
}
}
spanL = spanR = false;
do {
int res = WinAPI.SetPixel(hdc2, x, y, newColor);
if (!spanL) {
if (x > 0 && AreEqual(ref oldColor, WinAPI.GetPixel(hdc2, x - 1, y))) {
pixels.Enqueue(new Point(x - 1, y));
spanL = true;
}
} else if (!AreEqual(ref oldColor, WinAPI.GetPixel(hdc2, x - 1, y))) {
spanL = false;
}
if (!spanR) {
if (x < img.Width - 1 && AreEqual(ref oldColor, WinAPI.GetPixel(hdc2, x + 1, y))) {
pixels.Enqueue(new Point(x + 1, y));
spanR = true;
}
} else if (!AreEqual(ref oldColor, WinAPI.GetPixel(hdc2, x + 1, y))) {
spanR = false;
}
} while (++y < img.Height && AreEqual(ref oldColor, WinAPI.GetPixel(hdc2, x, y)));
} while (pixels.Count > 0);
WinAPI.BitBlockTransfer(hdc2, hdc1, 0, 0, 0, 0, img.Width, img.Height, WinAPI.TRO.SRCCOPY);
} catch {
return false;
} finally {
if (hdc2 != IntPtr.Zero)
WinAPI.DeleteDC(hdc2);
if (g != null) {
if (hdc1 != IntPtr.Zero)
g.ReleaseHdc(hdc1);
g.Dispose();
}
}
return true;
}
Jeff
|
|
|
|
|
Read my image processing articles.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Yep, that pointer implementation worked nicely. I now have four working implementations... One is with the built in GetPixel and SetPixel methods (excruciatingly slow), the second uses Win API GetPixel and SetPixel methods (as in the first post of this thread) (pretty slow), the third uses the LockBits method on the Bitmap, then I use Marshal.ReadInt32 and Marshal.WriteInt32 to modify the bitmap directly without using pointers (pretty fast), and the final way is to use int pointers and the LockBits method (blazingly fast!) The most unbeleivable part is that the pointer method is faster than the Win API ExtFloodFill method, and I even have WAY more control over how the fill is done (allowing near-matches in addition to exact matches). Thanks for the input!
Jeff
|
|
|
|
|
Hi Jeff,
for this I would stay clear from images if at all possible; a simple array should do,
you only need empty, border, and one or a few fill values.
As always, I prefer one-dimensional arrays over two-dimensional ones
(typically less code, more speed).
On the other hand, there are some CP articles on similar things such as this one.[^]
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Hi,
I have some problems with the updating of database. I will need to update 2 tables in one sql query and I am not too sure how to write a stored procedure with sql server. Need some guidance.
Thanks.
Regards,
Jo
|
|
|
|
|
Where are you stuck ? What does the proc look like ?
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
ALTER PROCEDURE [dbo].[UpdatePAppParty]
@PID VARCHAR(10),
@AID VARCHAR(10),
@name VARCHAR(50),
@designation VARCHAR(20),
@status VARCHAR(15),
@reasons VARCHAR(100)
AS
Begin
Update [aParty eStatus]
Set names = @name, designation = @designation, status = @status, reason = @reasons
where aParty.APID = estatus.APID and aParty.projectID = estatus.projectID
END
this is the procedure that i came out with. not too sure if it is correct.
Regards,
Jo
|
|
|
|
|
That's one update statement, so just add your second statement and you're done, right ?
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
i dont get what you mean by the second statment. The statement i have is to update 2 tables.
|
|
|
|
|
Have the second update statement for the next table with the appropriate condition. Encapsulate the Update statements in a TRANSACTION block so that if an error occurs in one update, the data integrity is preserved.
|
|
|
|
|
Hi friends,
I am making runtime application,
I have buttons , I want to receive the points(coordinates) of my buttons by using foreach method. Is there any property or method to give the coordinates of any controls(button, label, ...).
|
|
|
|
|
|
Hi.
I have created a dll from C code using MinGW. I try using it in my C# code, the code compiles, but the executable always hangs. If I use the dll in plain C code, the executable runs fine. I've gone through several tutorials and the dll always hangs if I try to run my compiled C# code. For reference, the last tutorial I attempted was this one.
What am I doing wrong? How can I access a dll, compiled with gcc under MinGW, in my C# code?
|
|
|
|
|
dfn wrote: What am I doing wrong?
Hard to say if you don't post your C# calling code.
|
|
|
|
|
Hi,
How can I get, the screen resolution of user by coding.
|
|
|
|
|
Screen.PrimaryScreen
It may be Screens.PrimaryScreen.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Thanks for your quick reply,
I don't understand your answer. I want to write a code to get computer's monitor's screen resolution.For example 1024x768 pixel. When, I changed the resolution from windows's normal options, I want to see it by clicking one button for example.
|
|
|
|
|