Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
this is a part of the documentation for a device I'm working on.
any idea how to interpret this to an image or bitmap or anything usable?
this definition below is xml definitions
3.2.13. IMAGE
properties: content complex
children: IMAGE_DATA
used by: complexType Cbc_Result
attributes: Name Type Use Default Fixed Annotation
ImageType Type_Image required
DataSize xs:long required
This node gathers information on an images files calculated by the software(Image_Data represents entire content of an emf file representing an image)
sample data :
< IMAGE DataSize="6676" ImageType="3">< IMAGE_DATA>AQAAAGwAAAAAAAAAAAAAAMcAAABjAAAAA
AAAAAAAAABNEgAANQwAACBFTUYAAAEAFBoAAI0AAAAF
AAAAAAAAAAAAAAAAAAAAVgUAAAADAABAAQAA8AAAAAAAAAAAAAAAAAAAAADiBACAqQMAEQAAAAwA
AAAIAAAAEgAAAAwAAAACAAAAFAAAAAwAAAANAAAACQAAABAAAADIMgAAjBwAAAkAAAAQAAAAyDIA
AIwcAAALAAAAEAAAAMgAAABkAAAASwAAAEAAAAAwAAAABQAAACAAAAABAAAAAQAAABAAAAAAAAAA
AAAAADB1AAAwdQAAAA< /IMAGE_DATA>< /IMAGE>
Looks like Base64 encoded (with stripped == signes at the end) content of file in EMF format - http://en.wikipedia.org/wiki/Windows_Metafile.
Make sure to add needed number of = at the end (http://en.wikipedia.org/wiki/Base64 for details) to successfully use Conver.FromBase64 function to get byte array.
I don't know if regular rendering methods support EMF... But Check Drawing namespace and Image class in particular.
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I want to put check to validate textbox that input value must not be similar to the values already present in database. Like:
if there is value with text "Hello" in database then user must not be allowed to save value either he writes:
Hello
HELLO
hElLo
HeLLO
Hello etc
I followed this http://www.dotnetperls.com/string-isupper-islower but as i am new to c# so have little confuse that how to match above defined words as all are same words Hello
I typically just convert both values (user input and stored value) to lower case when making the comparison.
Edit: if both values are in .NET, you could use String.Compare(s1, s2, StringComparison.OrdinalIgnoreCase)
Do you need to do this in code? I would suggest that you just make a unique constraint on the column and let the database handle that for you. Depending on the database you are using you may need to do a little additional work to handle the case sensitivity.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I´m using C# to create and format a Excel spreadsheet, so I need to format (merge cells, change the font, etc) until the final of the first page. How can I know the final line of the page in the Excel spreadsheet?
The following code will give you the last row number before every horizontal page break in an Excel worksheet:
foreach (Excel.HPageBreak pageBreak in worksheet.HPageBreaks)
{
int row = pageBreak.Location.Row - 1;
// ...
}
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
I have a requirement to allow user to upload any file (pdf, doc, ect) to sharepoint and later on download the file as needed. the upload and download tasks are implemented as asp.net web app. Currently, I convert the file content (byte array) to base64 string and store in sharepoint. For download, I get the content from sharepoint and do convert from base64 to string then I write this string to browser. The result did not look like original file. What is wrong?
From your question it sounds like the problem is you are converting the Base64 data to a string. Since Base64 is a representation of binary data using only printable characters it works fine as a string, but interpreting binary data directly as a string can result in data corruption. It's like trying to edit an EXE file using Notepad.
You need to convert the Base64 back to a byte array and write that to the browser.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I was looking for RSACryptoServiceProvider helper and found two different implementations
1) http://www.cnblogs.com/WYB/archive/2008/06/19/1225704.html
2) https://github.com/robvolk/Helpers.Net/blob/master/Src/Helpers.Net/EncryptionExtensions.cs
both of them working
var encryptedBytes = myBytes.RSAEncrypt(publicKey);
System.Text.Encoding.Unicode.GetString(encryptedBytes);
returns strings like "蹩巷Ӂය馧㾵봽놶徤蕺蓷課Ϝ堲泍썳⁙䃑ക늏...."
myString.EncryptStringUsingXMLFile(publicKey)
returns strings like "AnvFFT6YpoiAyIFwl+tueZq56Zcb0B7WhBEvz5uWl...."
May be some one can explain why first one producing Chinese strings and how to change that?
What approach is better?
To answer your first question. While it may look like it is producing Chinese characters what is actually happening is it is turning a byte array into unicode. In c# typically when you want to store a byte array you convert it to base64 which is what your second example appears to return.
Your first example would become this:
var encryptedBytes = myBytes.RSAEncrypt(publicKey);
Convert.ToBase64String(encryptedBytes) // this line changed
returns strings like "AnvFFT6YKpoiAy...."
As for what is recommended, the most common is to use base64. The reasons people use base64 over unicode or UTF-8 for binary data can be found in these answers:
https://stackoverflow.com/a/201491/701062
MSDN - Convert.ToBase64String(byte[])
http://msdn.microsoft.com/en-us/library/dhx0d524(v=vs.100).aspx
MSDN - Convert.FromBase64String(string) - Useful if you need to convert back into a byte array
http://msdn.microsoft.com/en-us/library/system.convert.frombase64string(v=vs.100).aspx
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I wanted to ask what do you think would be the best way to denoise an array of coordinate points.
I've got something like on the bottom drawing and need to convert it into what's on the top drawing.
Thanks :)
Median filter
A typical way of doing signal noise removal is a median filter.
If you have a noisy signal f(x), you can get a denoised signal g(x) by the following:
g(x) = medianz in R(x)(f(z))
where R(x) = [x-w/2, x+w/2] and w is some window width.
Example
Wikipedia has a concrete example.
Here's an example of denoising using a median filter. The first image is the source, the second image is the noisy version, the third image is the denoised version, and the fourth image is the difference between the source and the denoised versions. Notice that most of the error is near boundaries, whereas error in regions without sudden jumps is very low.
For a broader look at the topic, look at Noise reduction.