イメージにg.DrawString
という文字列を描画しています。私がこれをやる前に、私はソースイメージ上にイメージを描画しています。奇妙なDrawStringの動作
これは私のコードは次のようになります。
Bitmap sourceBitmap = Image.FromFile(myBitmap) as Bitmap;
Graphics g = Graphics.FromImage(sourceBitmap);
// drawing some other images on sourceBitmap with g.DrawImage
int positionx = 100;
Font ftemp = cvt.ConvertFromString(myfont) as Font; // predefined font
SizeF mysize = TextRenderer.MeasureText(mytext, ftemp);
PointF myposition = new PointF(positionx - mysize.Width, positiony) // align right
g.DrawString(mytext, ftemp, new SolidBrush(mycolor), myposition);
私が得る何が:
私は今、このようにすでに述べたように、コードの前に次の2行を追加する場合:
Bitmap sourceBitmap = Image.FromFile(myBitmap) as Bitmap;
Graphics g = Graphics.FromImage(sourceBitmap);
// drawing some other images on sourceBitmap with g.DrawImage
sourceBitmap = new Bitmap(sourceBitmap); // sourceBitmap is the bitmap (png) I'm drawing on from the very beginning.
g = Graphics.FromImage((Image)sourceBitmap);
int positionx = 100;
Font ftemp = cvt.ConvertFromString(myfont) as Font; // predefined font
SizeF mysize = TextRenderer.MeasureText(mytext, ftemp);
PointF myposition = new PointF(positionx - mysize.Width, positiony) // align right
g.DrawString(mytext, ftemp, new SolidBrush(mycolor), myposition);
私はこれを得る:
私はこれらの2つの線以外に何も変えなかった。だから私の質問は、これがどのように起こっているかということです。
よくwherreは最初のバージョンからの 'g'ですか? –
sourceBitmapからも。 –