Note that there are some explanatory texts on larger screens.

plurals
  1. POImage processing code help - C#
    primarykey
    data
    text
    <p>Alright y'all, time for more n00b help.<br> I've been working on this code in C# (Mono, to be exact). It is designed to take an image, break it down pixel by pixel, and write R,G, and B values as color coordinates to a text file.<br> Problem is, I don't get any processing. I simply get a red 0 (the percent function right above the for() loops, and an empty file. No text/coordinates generated. I'll post the console output below the code itself for clarity.</p> <pre><code>using System; using System.Drawing; using System.Drawing.Imaging; namespace Image_Interpreter_I { class MainClass { public static void Main (string[] args) { Console.WriteLine ("Enter filepath for bitmap image"); Console.ForegroundColor = ConsoleColor.Blue; string filepath = Console.ReadLine (); Console.ResetColor(); Bitmap image1 = new Bitmap(System.Drawing.Image.FromFile(filepath, true)); Console.WriteLine ("Enter filepath for file interpretation output"); Console.ForegroundColor = ConsoleColor.Blue; string filepath2 = Console.ReadLine(); Console.ResetColor(); int i; i = 1; int ImW, ImH; string ImWstr, ImHstr; Console.WriteLine ("Enter width of image:"); Console.ForegroundColor = ConsoleColor.Blue; ImWstr = Console.ReadLine (); Console.ResetColor (); ImW = Convert.ToInt16 (ImWstr); Console.WriteLine ("Enter height of image:"); Console.ForegroundColor = ConsoleColor.Blue; ImHstr = Console.ReadLine (); ImH = Convert.ToInt16 (ImHstr); decimal percent; percent = (i / (ImH * ImW)) * 100; Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine (percent); Console.ResetColor (); for (int y = 1; y &lt;= ImH; y++) { for (int x = 1; x &lt;= ImW; x++) { Color pixelColor = image1.GetPixel(x,y); byte r = pixelColor.R; byte g = pixelColor.G; byte b = pixelColor.B; string pixData = String.Format ("({0},{1},{2}", new object[] {r, g, b}); using (System.IO.StreamWriter file = new System.IO.StreamWriter(filepath2)) { file.WriteLine(pixData); } } } i++; } } } </code></pre> <p>Console Output:</p> <blockquote> <p>Enter filepath for bitmap image<br> /Users/user0/Desktop/IMG_1528.JPG<br> Enter filepath for file interpretation output<br> /Users/user0/Desktop/imageData.txt<br> Enter width of image:<br> 2448 Enter height of image: 3264 0</p> </blockquote>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload