|
Hi,
In the strCommand I am having 2MB of Data and when i am trying to split with the new line it was throwing error.(to loop through all the data)
But it was working for minminum (ie 50 KB of datas like 0's and 1's).
How to over come this error? Very urgent.. Below is the code...
CString strCommand; // Holds 2MB of datas like 0's and 1's...
System::String* strDataReceived = "";
strDataReceived = strCommand;
__wchar_t split __gc[] = new __wchar_t __gc[1];
split [0] = '\n';
String *strSplitCommand[] = strDataReceived->Trim()->Split (split);
Please help..
Reg,
Subbu
|
|
|
|
|
What error on what line?
That code doesn't look like it would even compile...
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi,
IMO you should not try and split a 2MB string, what you should do is avoid you ever need nor obtain such a string in the first place. It doesn't make sense. Tackle the problem at the producer's side, not the consumer's.
|
|
|
|
|
Hi,
I need help in creating a waterfall display of my pixel data stored in a buffer. The stream of data needs to be displayed streaming down the screen as its being acquired from the camera.
I am using visual c++ (windows forms).
Can someone please help me to figure out how to achieve this display?
Thanks in advance
|
|
|
|
|
Hi all,
I m new here.
Actually i am learning cppunit testing. and i just want to know, can we write a test case for a method, without calling it?
or how to write a testcase for a void type method?
plzz reply as soon as possible.
|
|
|
|
|
Runish Kumar wrote: can we write a test case for a method, without calling it?
How can you test a method without even calling it? Do you mean mocking some method calls?
Runish Kumar wrote: or how to write a testcase for a void type method?
What is a void type method? A method takes no arguments or returns void?
Also this forum is for C++/CLI discussions. For standard C++, try the C++/MFC forum instead.
|
|
|
|
|
Hi there,
I have a huge problem with Graphics Object.
My application shows pictures in a picturebox. Now I want to draw
multiple frames (rectangles) onto the shown image (regions of interest).
The most easy and acceptable way is to create a graphics object from the image and
do the drawRectangle function on it.
If the image is scaled or zoomed the rectangle(s) will always grow and shrink in same relations! this is very important!
Problem: My bitmap is format8bppindexed with a monochrome colorPalette added by myself, so I isn't possible to create
a graphics object!
It's very important, that I can refresh the images as fast as possible (best with just changing the scan0 pointer).
Is there a possible way to get a graphics object from such an image?
Or has anyone an idea how I could come up with that rectangle drawing thing?
I would be so happy about a good answer! Thanks and have a nice day...
|
|
|
|
|
I've personally always kept regions of interest separate from the image,
just drawing the ROIs at render time instead of drawing on the actual
image data.
A couple possibilities:
1) Use double buffering. Use a graphics object created for a bitmap with the same
bit depth as the screen. Draw the image to the graphics, draw the ROIs on the
graphics, and render the bitmap to the screen.
2) Use GDI directly via platform invoke.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi everyone, I am working on a project at least a year.
I have two major problems:
1.There is no way I can find out why my computer chrashes when running the program. It runs for a while then all of a sudden coputer restart itself. I am writing in Managed C++/cli using serialport class.
2. When the serial port communication is disconnected the program freez having problem detecting that as well.
FYI: I checked usb-serial converter latest driver, computer recognize it. I can see it through divice manager.( name of the usb-serial converter is Keyspan - USA 19HS).
Thanks in advance.
|
|
|
|
|
1 - Use logging and write the method entry and exits to the log file. By analyzing the log file, you can understand on which method it is failing.
2 - Is your application single threaded? If yes, use another thread to listen to the serial port. If serial port is not responding or disconnected, you should be able to abort the thread which listens to the port.
|
|
|
|
|
Hi Navaneeth, Sorry for delay, I am not sure how to do (1 - Use logging and write the method entry and exits to the log file. By analyzing the log file, you can understand on which method it is failing.) this.
If you be kind enough to tell me how I should do it. That will be very helpful. I am having this problem at least a year. I did everything I could do with my little knowledge nothing is helping. If I know what exacly coused computer to crash I may be able to find solution but I have no clue at all.
thanks;
|
|
|
|
|
Hi,
I haven't discovered a way yet to crash my computer using .NET code only.
One possibility for you is your USB-to-RS232C cable comes with a driver of doubtful quality, e.g. having a memory leak or a bug in its kernel code. So you may want and try it with another serial port, either a real one on a motherboard or expansion board, or a USB-to-RS232C cable from another manufacturer.
Another possibility could be something external to what you are doing, maybe a virus. You might try your USB-to-RS232C cable and your code on another system.
|
|
|
|
|
Hi Luc Pattyn, You probabily right because I am using a different usb-serial adapter altogether and now it did not chrash since then.
thank you.
|
|
|
|
|
Hello everyone, I am trying to get the folder name from openFileDialog box.
Here is what I need to do: when the Filedialog box is open I would select a file from a specific folder, get the folder name and assign to a variable as well, because I need to know from which folder the file came from.
I hope it is clear. if you can pls send me some code or some sort of solution I would greatly appriciate.
my code looks like this for now:
this->openFileDialog1->InitialDirectory = Environment::GetEnvironmentVariable("AppData") + "\\a\\b";
this->openFileDialog1->FileName = String::Empty;
this->openFileDialog1->Filter = "txt Files | *.txt";
this->openFileDialog1->ShowDialog();
Thanks in advance.
|
|
|
|
|
The System.IO.Path class has some handy methods for working
with paths.
Looks like Path.GetDirectoryName[^] could be what you need.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi Mark Salsbery,
Can you Please be little more specific.
Thanks
|
|
|
|
|
Specific as in a code example? I thought the examples at the link I posted
were pretty specific...
String ^FolderString;
if (!String::IsNullOrEmpty(this->openFileDialog1->FileName))
{
FolderString = System::IO::Path::GetDirectoryName(this->openFileDialog1->FileName);
}
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi Mark Salsbery,
I just want to say Thank you very much for your help.
All I had to add is : folderName = FolderString->Split('\\')[6];
because I was interested for the folder name.
so final code looks like this.
if (!String::IsNullOrEmpty(this->openFileDialog1->FileName))
{
FolderString = System::IO::Path::GetDirectoryName(this->openFileDialog1->FileName);
folderName = FolderString->Split('\\')[6];
}
Thanks again;
|
|
|
|
|
How can I draw smooth text on a transparent bitmap using GDI functions?
What I do is:
1- Creating myBitmap
2- Creating Graphics object from myBitmap
3- Getting bitmap hDC
4- Setting background mode to TRANSPARENT
5- Drawing text using DrawText function
6- Releasing bitmap HDC
7- Saving Bitmap
The result is an ugly text! the text is not smoothed but when I set background mode to OPAQ using SetBkMode the result is smoothed.
How can I draw smooth text on a transparent bitmap using GDI functions?
any help will be appreciated.
My code is like this:
Bitmap myBitmap=new Bitmap(100,100,Format32bppArgb);<br />
Graphic g=Graphics.FromImage(myBitmap);<br />
IntPtr hDC=g.GetHDC();<br />
SetBkMode(hDC, TRANSPARENT);<br />
DrawText(hdc, "Test", -1, myrectangle,myflags);<br />
g.ReleaseHdc(hDC);<br />
myBitmap.Save("myBitmap.png",ImageFormat.Png);
modified on Thursday, August 20, 2009 6:54 AM
|
|
|
|
|
Hi,
Not 100% sure but I don't think you can get smooth text on transparent backgrounds. Font smoothing normally happens by blending foregroundColor and backgroundColor at the edges of the glyphs; nothing blends with transparent, whatever you add to it remains transparent.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Thank you for your comment.
But using GDI+, when you draw a text on transparnet background and save the image you will see that the font smoothing is completely good. It seems here font smoothing take place by Mixing Font color with Transparent color, using Alpha value in ARGB.
Also Applications like Photoshop do the job well. So there should be a win32(GDI)approach to drawing smooth text on transparent bitmaps.
in GDI+ the code is like to this:
Bitmap myBitmap=new Bitmap(100,100,Format32bppArgb);<br />
Graphic g=Graphics.FromImage(myBitmap);<br />
g.DrawString("Test", Font, Brushes.Black, 0, 0);<br />
myBitmap.Save("myBitmap.png",ImageFormat.Png);
|
|
|
|
|
How can I convert Glyph Index to Unicode encoding?
The GetCharacterPlacement API function is useful for convert a sequence of unicode carachters to Glyph Indices, but is there a solution for convert a sequence of Glyph Indices to unicode carachters?
(I asked this question in c# forum but I received no reply)
any help will be appreciated.
|
|
|
|
|
Is there any way to draw high quality text glyph by glyph using GDI+?
When we draw a String using GraphicsPath.AddString, The SubPathes in the main path are glyph outlines. but it seems in small fonts the quality of Drawing string this way is not acceptable.
Is the result of GraphicsPath.AddString equal to GetGlyphOutline API function?
(I asked this question in c# forum but I received no reply)
any help will be appreciated
|
|
|
|
|
Hello, This is Vikash
I have a project written in VC++.net 2005.
I am writing the same project in VB.net 2005.
Now the problem is in VC++.net, when i am using an array of bytes and adding bytes values, and while debugging when i see the values filled in the array, along with the byte it also shows some character.
Now I want to ask whether this is being shown by VC++ itself by default or something else.
Actually i have checked this and found that the character shown is actually the Character that the Byte represents as ASCII value.
eg. it shows 65 'A' as the value in the array element where 65 is the inserted byte.
Could you please tell me where this character is coming from.
Any help is appreciated.
Thanks in Advance.
|
|
|
|
|
VikashGohil wrote: Actually i have checked this and found that the character shown is actually the Character that the Byte represents as ASCII value.
eg. it shows 65 'A' as the value in the array element where 65 is the inserted byte.
You seem to have answered your own question. A byte with the value 65 represents the character 'A' in the ASCII encoding.
|
|
|
|