bin ich auf folgendern überaus gut erklärten Post von herbivore auf myCSharp.de gestoßen, den ich im Folgenden einfach übernehmen werde:
| |||
|
Danke herbivore :)
| |||
|
Installing services | |||||||||
The safest way to manually install the service is to use the provided service.bat script. Administrator privileges are required to run this script. If necessary, you can use the NOTE: On Windows Vista or any other operating system with User Account Control (UAC) you must either disable UAC or right-click on cmd.exe and select "Run as administrator" in order to run this script. If UAC is enabled neither being logged on with an Administrator account, nor using the |
C:\jazz\server\tomcat\bin\service.bat install
C:\jazz\server\jre\bin\j9vm\jvm.dll
-DJAZZ_HOME=file:///c:/jazz/server/conf -Djava.awt.headless=true -Dorg.eclipse.emf.ecore.plugin.EcorePlugin.doNotLoadResourcesPlugin=true -Dcom.ibm.team.repository.tempDir=%TEMP% -Djazz.connector.sslProtocol=SSL_TLS -Djazz.connector.algorithm=IbmX509 -Dlog4j.configuration=file:///c:/jazz/server/conf/startup_log4j.propertiesWenn Sie eine Oracle-Datenbank verwenden, fügen Sie folgende Zeile hinzu:
-DORACLE_JDBC=[Pfad zur Oracle JDBC-Treiber-JAR]Falls Sie eine SQL-Server-Datenbank verwenden, fügen Sie auch die folgende Zeile hinzu:
-DSQLSERVER_JDBC=[Pfad für die SQL Server JDBC-Treiber-JAR]
set CATALINA_OPTS=-Dcom.ibm.team.server.configURL=file:///"%cd%"/teamserver.properties -Dlog4j.configuration=file:///"%cd%"/log4j.properties set JAVA_OPTS=-Djava.awt.headless=true -DORACLE_JDBC="%ORACLE_JDBC%" -DDB2I_JDBC="%DB2I_JDBC%" -DDB2Z_JDBC="%DB2Z_JDBC%" -Dorg.eclipse.emf.ecore.plugin.EcorePlugin.doNotLoadResourcesPlugin=true -Dcom.ibm.team.repository.provision.profile="%cd%"\provision_profiles -Dcom.ibm.team.repository.tempDir=%TEMP% -Xmx700M
GetPixel
method of the GDI+ Bitmap
class to compare each pixel in the first image with the corresponding pixel in the second image. If at any point, the two pixels did not match then we can safely say that the images are different. If, however, we got to the end of the comparison tests without any mismatches then we can conclude that the two images are indeed identical.public static CompareResult Compare(Bitmap bmp1, Bitmap bmp2)
{ CompareResult cr = CompareResult.ciCompareOk;
//Test to see if we have the same size of image
if (bmp1.Size != bmp2.Size)
{
cr = CompareResult.ciSizeMismatch;
}
else
{
//Sizes are the same so start comparing pixels
for (int x = 0; x < bmp1.Width && cr == CompareResult.ciCompareOk; x++)
{
for (int y = 0; y < bmp1.Height && cr == CompareResult.ciCompareOk; y++)
{
if (bmp1.GetPixel(x, y) != bmp2.GetPixel(x, y))
cr = CompareResult.ciPixelMismatch;
}
}
}
return cr;
}
This method worked fine but with one major drawback, speed, or rather the lack of it. Comparing two 2000 x 1500 pixel images using this method took over 17 seconds! With over 200 images to compare, this meant that my tests would take nearly an hour to complete and I wasn't prepared to wait that long.GetPixel
, I decided that it would be quicker if I could some how compare a 'hash' of each image to see if they were identical. As we know, a hash is a unique value of a fixed size representing a large amount of data, in this case our image data. Hashes of two images should match if and only if the corresponding images also match. Small changes to the image result in large unpredictable changes in the hash.System.Security.Cryptography
namespace such as SHA1 and MD5 but I decided to use the SHA256Managed
class. The ComputeHash
method of this class takes a byte array of data as an input parameter and produces a 256 bit hash of that data. By computing and then comparing the hash of each image, I would be quickly able to tell if the images were identical or not.Bitmap
objects to a suitable form for passing to the ComputeHash
method, namely a byte array. Initially, I looked at the LockBits
method of the Bitmap
class which allowed me access to the individual pixel bytes but it would have meant a journey into the land of unmanaged code and that was somewhere I really didn't want to visit. Instead, GDI+ kindly provides an ImageConvertor
class to allow us to convert Image
(or Bitmap
) objects from one data type to another, such as a byte array.using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.Security.Cryptography;
namespace Imagio
{
public class ComparingImages
{
public enum CompareResult
{
ciCompareOk,
ciPixelMismatch,
ciSizeMismatch
};
public static CompareResult Compare(Bitmap bmp1, Bitmap bmp2)
{
CompareResult cr = CompareResult.ciCompareOk;
//Test to see if we have the same size of image
if (bmp1.Size != bmp2.Size)
{
cr = CompareResult.ciSizeMismatch;
}
else
{
//Convert each image to a byte array
System.Drawing.ImageConverter ic =
new System.Drawing.ImageConverter();
byte[] btImage1 = new byte[1];
btImage1 = (byte[])ic.ConvertTo(bmp1, btImage1.GetType());
byte[] btImage2 = new byte[1];
btImage2 = (byte[])ic.ConvertTo(bmp2, btImage2.GetType());
//Compute a hash for each image
SHA256Managed shaM = new SHA256Managed();
byte[] hash1 = shaM.ComputeHash(btImage1);
byte[] hash2 = shaM.ComputeHash(btImage2);
//Compare the hash values
for (int i = 0; i < hash1.Length && i < hash2.Length && cr == CompareResult.ciCompareOk; i++)
{
if (hash1[i] != hash2[i])
cr = CompareResult.ciPixelMismatch;
}
}
return cr;
}
}
}
markrouse
Web Developer
United Kingdom Member | Mark Rouse works as a software developer for Imagio Technology in Yorkshire, UK When not working on his favourite charting component, SimpleChart, Mark is providing custom application development for his clients using ASP.NET, C# and SQL Server and in particular Web Services. |
Dear App Inventor User,
As we announced on the App Inventor Announcement Forum, Google will end support for App Inventor on December 31, 2011, after which data in appinventorbeta.com will not be accessible and will be deleted from Google servers. You can preserve your App Inventor projects by simply clicking on the Download All Projects button on your My Projects page. This will download to your computer a zipped archive of all your projects. We recommend you retrieve your projects well before December 31st.
By the end of 2011 Google will also be making the complete App Inventor source code publicly available under an open source license, so that anyone can study the code and modify it as they desire. In order to ensure the future success of App Inventor, Google has funded the establishment of a Center for Mobile Learning at the MIT Media Lab. Sometime in the first quarter of 2012, the Center plans to provide an App Inventor service for general public access, similar to the one Google is currently running. In order for you to continue working with your projects in an open source instance (MIT or otherwise) of App Inventor you will need to download your data from appinventorbeta.combefore December 31st and later upload them to an open source instance as it becomes available. Please visit the App Inventor user forums to get future updates on App Inventor. You can also visit http://mobilelearning. The App Inventor Team |
nur bis 21.11.2011 --- 0,00 EUR danach 7,95 EURDas Drupal 6 Praxisbuch Alter preis: 34,95 EUR Jetzt nur: 0,00 EUR weiter» Neuheiten Restposten eBooks bis 1,00 EUR Nochmal reduziert |
10% Rabatt für Kategorie:Grafik-CAD-Video 10% Rabatt für Kategorie: Grafik-CAD-Video von 31.10.11 bis 07.09.09 nur für Newsletterempfänger Coupon Code: graf31 |
Method that uses Regex.Replace [C#] ////// Converts all whitespace in the string to spaces using Regex. /// public static string ConvertWhitespaceToSpacesRegex(string value) { value = Regex.Replace(value, "[\n\r\t]", " "); return value; }
Method that uses string Replace [C#] ////// Converts all whitespace in the string to spaces using string Replace. /// public static string ConvertWhitespaceToSpacesString(string value) { value = value.Replace('\r', ' '); value = value.Replace('\n', ' '); return value; }
Method that uses ToCharArray and switch [C#] ////// Converts all the whitespace in the string to spaces using switch. /// 3-4x faster than using string replace. /// Faster than using a new empty array and filling it. /// public static string ConvertWhitespaceToSpaces(string value) { char[] arr = value.ToCharArray(); for (int i = 0; i < arr.Length; i++) { switch (arr[i]) { case '\t': case '\r': case '\n': { arr[i] = ' '; break; } } } return new string(arr); }
Method that replaces newlines [C#] ////// Converts all newlines in the string to single spaces. /// public static string ConvertNewlinesToSingleSpaces(string value) { value = value.Replace("\r\n", " "); value = value.Replace('\n', ' '); return value; }
Method that converts to UNIX newlines [C#] ////// Converts Windows style newlines to UNIX-style newlines. /// public static string ConvertToUnixNewlines(string value) { return value.Replace("\r\n", "\n"); }
Method that converts to Windows newlines [C#] ////// Converts all newlines in the file to Windows newlines. /// public static string ConvertToWindowsNewlines(string value) { value = ConvertToUnixNewlines(value); value = value.Replace("\n", "\r\n"); return value; }
Method that uses Regex.Replace [C#] ////// Convert all whitespaces to a single space. /// public static string ConvertWhitespacesToSingleSpaces(string value) { value = Regex.Replace(value, @"\s+", " "); return value; }
Method that uses File.ReadAllText [C#] using System; using System.IO; class Program { static void Main() { // // Read in text with File.ReadAllText. // string value = File.ReadAllText("TextFile1.txt"); // // Call method and display result. // value = NewlineTool.ConvertWhitespacesToSingleSpaces(value); Console.WriteLine(value); // // You can now write it with File.WriteAllText. // } }
Example of static class [C#] using System.Text.RegularExpressions; ////// Contains string methods for converting newlines. /// public static class NewlineTool { ////// Converts all whitespace in the string to spaces using Regex. /// public static string ConvertWhitespaceToSpacesRegex(string value) { // ... } }