Magische Zahlen in Farb- und Image-Raum-TransformationC#

Ein Treffpunkt für C#-Programmierer
Anonymous
 Magische Zahlen in Farb- und Image-Raum-Transformation

Post by Anonymous »

Bitte identifizieren Sie unten; Ich habe vergessen, wie ganzzahliger Überlauf funktioniert>.

Nachdem ich die unglaublichen Antworten auf diese Frage mit Code -Golf gesehen hatte, dachte ich, ich könnte mich mit dem Generieren meiner eigenen Bilder in C#anlegen. Ich stolperte eine Weile herum, versuchte, ein XOR -Plot zu erstellen, und stellte fest, dass das direkte Schreiben in Komponenten (z. B. rot = a ^ b ) nicht funktioniert hat, aber das Schreiben von Triggfunktionen um Logarithmen um einen Kern a ^ b hat; Gibt es einen Grund dafür?

Code: Select all

ColorVec currColor = new ColorVec((float)Math.Sin(Math.Log(j ^ i)),
(float)Math.Cos(Math.Log(j ^ i)),
(float)Math.Tan(Math.Log(i ^ j)));
< /code>

Konstruktor für ColorVec < /code>: < /p>

public ColorVec(float xR, float yG, float zB)
{
red = xR;
green = yG;
blue = zB;
}
< /code>

Funktionen zwischen Gleitkomma-Farben und den acht Bitfarben, die nach Bitmap erwartet werden < /code>: < /p>

public byte GetIntRed()
{
return (byte)(red * 255);
}

public byte GetIntGreen()
{
return (byte)(green * 255);
}

public byte GetIntBlue()
{
return (byte)(blue * 255);
}
< /code>

Programmcode: < /p>

class Program
{
static void Main(string[] args)
{
short width = 2048;
Random rand = new Random();
Bitmap imageWriting = new Bitmap(width, width);

for (short i = 0; i < width; i += 1)
{
Console.WriteLine(String.Concat("Working... (writing batch ", i, " of ", width, ")"));

for (short j = 0; j < width; j += 1)
{
ColorVec currColor = new ColorVec((float)Math.Sin(Math.Log(j ^ i)),
(float)Math.Cos(Math.Log(j ^ i)),
(float)Math.Tan(Math.Log(i ^ j)));

imageWriting.SetPixel(i, j, Color.FromArgb(1, currColor.GetIntRed(),
currColor.GetIntGreen(),
currColor.GetIntBlue()));
}
}

imageWriting.Save("test.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
}
}

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post