さて、このメソッド Resize をクラス Object2D で作成しました。これは、呼び出される Object2D の 2 次元の Color-Array PointInformation を特定の割合でサイズ変更することになっています。(2D 配列を 1D 配列に変換する方が簡単であることがわかりました)
public class Object2D
{
int width;
int height;
int ResizePercentage = 100;
Color PointInformation[][];
public void Resize(int Percentage)
{
Color[]temp = Standart_Methods.Reduce2DArray(this.PointInformation);
int temp_width = this.width;
int temp_height = this.height;
double Faktor = (Percentage+100)/100;
this.width = (int) (this.width*Faktor);
this.height = (int) (this.height*Faktor);
this.ResetPointInformation();
Color[]temp2 = Standart_Methods.Reduce2DArray(this.PointInformation);
int SamePixelCount = 0;
Color LastColor = temp[0];
for (int i = 0; i < temp.length; i++)
{
if (temp[i] == LastColor )
{
SamePixelCount += 1;
}
else
{
for (int i2 = (int) (i*Faktor); i == 1; i-- )
//Method Resize will only be called when i*Faktor is going to be 100% = X.0 (An Integer)
{
temp2[i*2-i] = LastColor;
}
SamePixelCount = 0;
}
}
Standart_Methods.PrintArray(temp2);
int a = 10;
int b = 0;
System.out.print(a/b); //No Exeption, Code unreachable!?
}
}
基本的に temp[0] から開始し、同じ色が見つかる限り、int SamePixelCount に 1 を追加します。別の色が見つかると、メソッドは前のピクセルの色を temp2 配列の正しい場所に書き込みます。
for (int i = 0; i < temp.length; i++)
{
if (temp[i] == LastColor )
{
SamePixelCount += 1;
}
else
{
for (int i2 = (int) (i*Faktor); i == 1; i-- )
//Method Resize will only be called when i*Faktor is going to be 100% = X.0 (An Integer)
{
temp2[i*2-i] = LastColor;
}
SamePixelCount = 0;
}
}
操作された配列 temp2 のオブジェクトの PointInformation への正しい変換はまだありません。これは、temp2 が一時から正しくサイズ変更されたかどうかをテストしたかったためです。
Standart_Methods.PrintArray(temp2); //the Method works btw
しかし、それは何もしませんでした!そしてさらに悪い!そのコマンドの場所に置いたものはすべて、そうではありませんでした!
int a = 10;
int b = 0;
System.out.print(a/b); //No Exeption!
さらに奇妙なのは、どこかで Method Resizeを呼び出すとすぐに、 Call の後のすべてが同じ奇妙な到達不能コードに変わることです!?
この問題の原因について、私は真剣にまったく無知です。
どんな助けでもいいです!