Hi all, I'm wondering how many guys here are experiencing the MySql bug which just popped out with the installation of VS2010 SP1, reported here: http://bugs.mysql.com/bug.php?id=60404[^] Sadly I'm one of them, and I'd like to know if it's just me and some other guys (in this case I'd try a fresh reinstall), or this is a general bug which must be addressed. Thanks!
Daniele Fusi
Posts
-
MySql connector and VS2010 SP1 -
newbie: Bitmap.CopyPixels with B/W imagesHi all, I'm new to WPF and I'm experimenting with 3.0 bitmaps: I've created a dummy sample code which should: 1) load a bitmap file from disk. It's supposed to be a very small bitmap (e.g. 32x32, 200x100, etc), usually B/W. 2) convert the bitmap to B/W (if required) and get an array representing the black/white pixels. For testing, I "dump" these pixels into a textbox with a fixed-pitch font (e.g. Courier New), by outputting a line for each bitmap row, where '.' represents the 'background' pixel (e.g. white) and '#' the foreground pixel (e.g. black). This way the textbox should give a sketch of the picture. This seems to work fine for non B/W bitmaps, and I can get the 'picture'; but as soon as I convert the loaded bitmap to B/W the textbox shows no more the 'picture', but this seems to be shrunken to occupy just a narrow leftmost portion of the dumped area. Also, I get a set of various values from CopyPixels in a B/W image, while I'd expect just 2, representing black and white. What am I doing wrong here? Here's a sample:
// load a bitmap eventually converting to B/W private BitmapSource LoadBitmap(string sFile, bool bConvertToBW) { BitmapImage bmp = new BitmapImage(new Uri(sFile)); if (bConvertToBW) return new FormatConvertedBitmap(bmp, PixelFormats.BlackWhite, BitmapPalettes.BlackAndWhite, 0); return bmp; } // Handler for Load... button: private void OnLoad(object sender, RoutedEventArgs e) { OpenFileDialog dlg = new OpenFileDialog(); dlg.Filter = "Bitmap Files (*.bmp)|*.bmp"; if (dlg.ShowDialog() != true) return; // load (and convert to BW if required) // IF I PASS true I GET THE ISSUE DESCRIBED ABOVE. WITH false THE DUMP SEEMS TO WORK BitmapSource bs = LoadBitmap(dlg.FileName, true); int nBytesPerPixel = (bs.Format.BitsPerPixel + 7) / 8; int nStride = bs.PixelWidth * nBytesPerPixel; byte[] aPixels = new byte[bs.PixelHeight * nStride]; bs.CopyPixels(aPixels, nStride, 0); // quick and dirty dump pixels to text (BACKGROUND is just a constant I manually set to 0, 255 etc // according to the image I'm testing with, and represents the background color) StringBuilder sb = new StringBuilder(); int nRow; for (int y = 0; y < bs.PixelHeight; y++) { if (y > 0) sb.AppendLine(""); nRow = y * nStride; for (int x = 0; x < bs.PixelWidth; x++) sb.Append(aPixels[nRow + x * nBytesPerPixel] == BACKGROUND ? '.' : '#'); } _txtOut.Text = sb.ToString(); }
Thanks! -
XslTransform and document():confused:I'm writing a C# app which uses some xslt scripts to transform XML files. The XSLT files are embedded as resources in the application assembly. Some of these files use 2 input: one is the XML file to be transformed, another is an XML fragment contained in a distinct file, accessed via document() XSL function. The location of this second input file is known at runtime, and is passed from the application to the Transform method using an XsltArgumentList. The code I have written works fine if I load the XSLT from file, but the transformation *fails to access the 2nd input document when I load it from the assembly resources*. In both cases, the parameter is received correctly and the transformation works except for the external document data, which in one case are completely ignored as if the document did not exist. Maybe I'm missing some credentials, or what else can be wrong? Thx guys for helping a newbie... :-) Here's a dummy sample: --- let's say we have a dummy contacts list in a XML file, and I want to prepend some XML coming from another file; the XSLT looks like: ... where the full path for the file to be prepended is passed as "newdoc" parameter. I add the tags above to examine the parameter value. --- the code for the transformation follows: it works fine if I use the Load from file method, but FAILS if I load the XSLT from resources. In both cases, I can be sure that the parameter is received correctly, but it seems that the XSLT loaded from resources CANNOT ACCESS the file using document() function ( above is always empty, while contains the file name as expected): // setup params XsltArgumentList xlArgs = new XsltArgumentList(); xlArgs.AddParam("newdoc", "", "c:\\Work\\SomeDummyFile.xml"); // load input XML XPathDocument doc = new XPathDocument("c:\\Work\\theInputFile.xml"); // open output XmlTextWriter wr = new XmlTextWriter("c:\\work\\theOutputFile.xml"), null); wr.Formatting = System.Xml.Formatting.Indented; // transform XmlUrlResolver res = new XmlUrlResolver(); res.Credentials = System.Net.CredentialCache.DefaultCredentials; XslTransform xslt = new XslTransform(); // xslt.Load("c:\\work\\Test.xslt"); <-