BCB6でStretchDrawを使いたい!

このQ&Aのポイント
  • BCB6でStretchDrawを使いたいですが、TBitmapに書き出す際にうまくいきません。
  • Formなどに書き出す場合は問題ありませんが、TBitmapに書き出そうとするとできません。
  • 現在、Graphics::TBitmapというクラスを使用していますが、正しくStretchDrawが動作しないため困っています。
回答を見る
  • ベストアンサー

BCB6でStretchDrawを使いたいのですが

BCB6でStretchDrawを使いたいのですが Formなどに書き出す場合は出来るのですが TBitmapを用意してそこに書き出そうとすると出来ません Graphics::TBitmap *Bitmap1 = new Graphics::TBitmap(); Graphics::TBitmap *Bitmap2 = new Graphics::TBitmap(); Bitmap1 = Image1->Picture->Bitmap; TRect e; e.Top=0; e.Left=0; e.Right = 450; e.Bottom = 450; Bitmap2->Canvas->StretchDraw(e,Bitmap1); Image2->Picture->Assign(Bitmap2); わかりにくいでしょうが よろしくお願いいたします。

  • gotyan
  • お礼率91% (172/188)

質問者が選んだベストアンサー

  • ベストアンサー
  • kmb01
  • ベストアンサー率45% (63/138)
回答No.1

Bitmap2->Width = 450; Bitmap2->Height = 450;

gotyan
質問者

お礼

ありがとうございます Bitmap2に幅,高さを指定するが出来ていなかったんですね。 大変助かりました ありがとうございます。

関連するQ&A

  • bmpやImageの配列を関数の引数で渡す

    C++BuilderXE2starterです。 ビットマップ(bmp)やTImage を配列で定義し、関数の引数として渡したいのですが よくわからないまま、次のようにすると、色んな不正な使い方らしきエラーとなります。 正しい使い方を教えてください。 なお配列でないbmpを渡すことはできます。ImageはIDEで定義するのではなく、プログラムから生成させる積もりです。 最終的にやりたいスタイル。 void __fastcall TForm1::onclick(TObject *Sender) { int n; Graphics::TBitmap *bmp[10]; TImage::Image *Imagenum[10]; for(n=0;n<10;n++){ bmp[n]=new Graphics::TBitmap(); Imagenum[n]=new TImage::TImage; // bmp,Imagenum のサイズ位置の設定 Imagenum[n]->Top= 値; Imagenum[n]->Left= 値; } sub(bmp,Imagenum); Free(bmp); // for でまわす要あり? Free(Image); } //--------------------------------------------------------------------------- void TForm1::sub2(Graphics::TBitmap *bmp[], TImage *Imagenum[]) { Image[0]->Canvas->Draw(0,0,bmp[0]); Image[1]->Canvas->Draw(0,0,bmp[1]); } unit.h class TForm1 : public TForm { __published: // IDE で管理されるコンポーネント TButton *Button1; void __fastcall onclick(TObject *Sender); private: // ユーザー宣言 void TForm1::sub(Graphics::TBitmap **bmp, TImage **Image); public: // ユーザー宣言 __fastcall TForm1(TComponent* Owner); };

  • C# 印刷可能領域と余白範囲の関係?

    C# 印刷可能領域と余白範囲の関係? プリンタで印刷出来る最大画像を出力したい そこで余白範囲を印刷可能範囲まで拡大した private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e) { MessageBox.Show("余白範囲 変更前" + "\r\n" + " left " + e.MarginBounds.Left + "\r\n" + " right " + e.MarginBounds.Right + "\r\n" + " width " + e.MarginBounds.Width + "\r\n" + " top " + e.MarginBounds.Top + "\r\n" + " bottom " + e.MarginBounds.Bottom + "\r\n" + " height " + e.MarginBounds.Height + "\r\n");    余白範囲を印刷可能範囲まで拡大 e.PageSettings.Margins.Left = (int) e.Graphics.VisibleClipBounds.Left; e.PageSettings.Margins.Right = (int)e.Graphics.VisibleClipBounds.Right; e.PageSettings.Margins.Top = (int)e.Graphics.VisibleClipBounds.Top; e.PageSettings.Margins.Bottom = (int)e.Graphics.VisibleClipBounds.Bottom;    このようにしても前後のメッセージの値は同一でした MessageBox.Show("余白範囲内 変更後" + "\r\n" + " left " + e.MarginBounds.Left + "\r\n" + " right " + e.MarginBounds.Right + "\r\n" + " width " + e.MarginBounds.Width + "\r\n" + " top " + e.MarginBounds.Top + "\r\n" + " bottom " + e.MarginBounds.Bottom + "\r\n" + " height " + e.MarginBounds.Height + "\r\n"); } どうやら余白範囲はReadOnlyらしい そこで疑問??? (1)余白範囲を超えても印刷可能範囲ならば、全てのプリンタで画像がチョン切れることはないのだろうか? (2)そうならば余白範囲は何のためにあるのでしょうか? その存在目的は? 毎日印刷テストを繰り返し、無駄なインクと紙を浪費している私と『 母なる地球 』をお救いください!!!

  • BCBで画像を拡大印刷したい

    C++Builder5を使っています。 会社で印刷するプリントに会社のロゴを同時に印刷したい、という要求があり、BMPを印刷するテストプログラムを作りました。 ロゴの画像は300dpiでスキャンしたものをBMPにしてファイルとして保存してあります。 ソースの抜粋は次のとおりです。 int x,y; Graphics::TBitmap *pBitmap = new Graphics::TBitmap(); pBitmap->LoadFromFile(FLNM); //FLNMにはBMPファイル名が格納されています。 Printer()->Canvas->Draw(x,y,pBitmap); xとyは、 GetDeviceCaps(Printer()->Handle,LOGPIXELSY)でプリンターの解像度を得て、印刷位置をドットに変換済みです。 これで画像は希望する位置に印刷できたのですが、(当初から予想はしていましたが)問題があります。 プリンターの解像度によって画像の大きさが変わってしまいます。 プリンターの解像度に合わせて画像を拡大印刷したいのですが、方法はあるでしょうか? 例えば、プリンター解像度が600dpiなら縦横2倍の大きさで印刷する、ということです。 TBitmapのHeightを2倍にしてみたのですが、元の画像に余白が追加されただけで、希望通りの大きさでは印刷できませんでした。 よろしくご指導ください。

  • CSSのcaption-side:・・・

    続けて質問すみません。 CSSのcaption-side:なのですが、 right / left / bottom はテーブルのどこに配置されるのが正しい配置ですか?        TOP   ┏━━━━━━━━━━━┓   ┃              ┃   ┃              ┃ left┃              ┃right   ┃              ┃   ┃              ┃   ┗━━━━━━━━━━━┛        bottom ですか?  left   TOP  right ┏━━━━━━━━━━━┓ ┃              ┃ ┃              ┃ ┃              ┃ ┃              ┃ ┃              ┃ ┗━━━━━━━━━━━┛      bottom ですか?

  • 【C#】GraphicsのhDcについて

    C#でアプリケーションを作成しています。 PictureBoxに読み込んだ画像を画像処理ライブラリにGraphicsのhDcを渡し、処理をさせたいのですが、 Bitmap bmp = new Bitmap("ファイル名"); pictureBox1.Image = bmp; Graphics g = Graphics.fromImage(pictureBox1.Image); IntPtr hdc = g.GetHdc(); というふうに作った[hdc]を渡すと真っ黒な画像が表示されてしまいます。 ピクチャーボックス1のPaintイベント pictureBox1_Paint(object sender, PaintEventArgs e) { // pictureBox1.Imageには上と同じ画像を読み込み済み IntPtr hdc = e.Graphics.GetHdc(); } というふうに作った[hdc]を渡すと、正常に処理された画像が表示されます。 質問なのですが、PictureBox1.Imageから作ったGraphicsとPaintEventArgs.Graphicsはどのような差があるのでしょうか? また、PaintEventArgsを使わず同じようなGraphicsを作るにはどうしたらいいでしょうか? 至らない説明で申し訳ありませんが、ご助言をよろしくお願いします。

  • div入れ子、親でmarginを設定すると子のmarginは反映されない?

    段組みレイアウトでdivが 入れ子になってています。 外側が <div id=wrap> <div id=main> <div id=form> </div> </div> </div> #wrap{ width: 840px; margin-top: 0px; margin-right: auto; margin-bottom: 15px; margin-left: auto; } #main { width: 582px; float: right; padding: 0; margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 10; } #form { width: 562px; padding: 0; margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 20; } としてあります。 id=formのmargin-left :20; だけがブラウザで反映されず、 flort:right;で右に寄せて左に20pxあけました。 id=mainもflort:right;で右に寄っているだけだったようです。 divを入れ子に使う場合、 親でmarginを設定したら、子のmarginは反映されないのでしょうか?

    • ベストアンサー
    • HTML
  • cssハックについて

    googleとfirefoxでcssが聞かない箇所があります。 css--------- #operation { width: 420px; background-image: url(../picture/top/left_middle.jpg); background-repeat: repeat-y; background-position: center top; margin-top: 10px; } #operation img { border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; } #operation #ope_top { background-image: url(../picture/top/left_top.jpg); background-repeat: no-repeat; background-position: left top; height: 30px; padding-bottom: 0px; margin-bottom: 0px; } #operation #ope_top #ope_tit { font-size: 14px; line-height: 2; font-weight: bold; color: #FFFFFF; text-indent: 10px; float: left; width: 200px; margin-top: 0px; padding-top: 0px; height: 20px; } #operation #ope_top .ope_img { padding-top: 5px; float: right; margin-right: 10px; } #operation #ope_middle { margin-top: 0px; padding-top: 0px; width: 420px; margin-left: -200px;←ここがおかしいです!! } #operation #ope_middle .content ul { margin-top: 5px; padding-left: 30px; list-style-image: url(../picture/list.jpg); } #operation #ope_middle .content li { margin-bottom: 5px; margin-top: 1px; } #operation #ope_middle .content .line01 { border: 1px dotted #CCCCCC; margin-top: 2px; margin-bottom: 2px; } というかんじなのですが、左右へとぶれてしまいます。 どのように修正したいいのか困っております。 参考になるようなことありましたらお願いします。

  • VB.NET ピクチャーボックスのImageの一部をクリップボードにコピー

    Picturebox1.Image = New Bitmap(Picturebox1.Width, Picturebox1.Height) Dim g As Graphics = Graphics.FromImage(Picturebox1.Image) これ以降 g.DrawLine 等で描画を行っています そして、ピクチャーボックスの一部の領域(矩形)を指定して クリップボードにコピーしたいのですがどうしたらいいでしょうか よろしくお願いします 他のピクチャーボックスにその一部をコピーできるだけでもいいのですが

  • ロールオーバーの挙動がおかしい

    あるページに <input type="button">や<input type="submiit"> によるボタンをいくつか配置しています。 CSSでボタンのスタイルを設定しており、hoverのスタイルも設定しています。 ボタンのひとつは、クリックすると別ウィンドウでリンクが開くようにしていますが IE8で見ると、このボタンだけロールオーバーが枠(罫線)にしか反応しません。 ボタンの枠の上にマウスがあるときはhoverの状態になり、ボタン本体(テキスト部やpadding部)にマウスがあるときは無反応です。 しかしFFではボタン全体でしっかり反応していました。 その他のボタンは、IEでもFFでも正しく動いています。 IE8のエラー回避方法を教えてください。 よろしくお願いいたします。 【CSS】 .button2 { padding: 1px 10px 1px 10px ; margin: 0px 3px 0px 3px ; border-top: 2px double #55bcb8; border-left: 2px double #55bcb8; border-right: 2px double #012a29; border-bottom: 2px double #012a29; background: #449592 left bottom repeat-x; text-align: center; text-decoration: none; display: block; font-size: 12px; color: #FFF; } .button2:hover{ padding: 1px 10px 1px 10px ; margin: 0px 3px 0px 3px ; border-top: 2px double #012a29; border-left: 2px double #012a29; border-right: 2px double #55bcb8; border-bottom: 2px double #55bcb8; background: #55bcb8 left bottom repeat-x; text-align: center; text-decoration: none; } 【HTML】 <form style="float:right; margin-right:20px;">    <input name="map" class="button2" onclick="window.open('地図.html','_blank','scrollbars=no,width=550,height=500'); return false;" type="button" value="map"/> </form>

    • ベストアンサー
    • CSS
  • C#で派生クラスから描画処理を行う

    C#を勉強しているのですが、GUIを作り初めて描画処理で分からない所があり、質問させて頂きます。 基本クラスの方で「Hello, world!」という文字列をDrawStringで表示させる事は出来たのですが、それを基本クラスを継承した派生クラスのメソッドで行うと何も表示されないんです。 以下が試したコードです。 //基本クラスSample1 using System; using System.Drawing; using System.Windows.Forms; public class Sample1 : Form {   protected Bitmap image; protected Graphics g; protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); Sample2 s = new Sample2(); s.helloworld(); e.Graphics.DrawImage(image, 0, 0); } public Sample1() { SetStyle(ControlStyles.DoubleBuffer | ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true); image = new Bitmap(600, 400); g = Graphics.FromImage(image); } static void Main() { Form form = new Sample1(); form.Text = "sample"; form.ClientSize = new Size(600, 400); form.BackColor = Color.FromArgb(0xff, 0xff, 0xff); Application.Run(form); } } //派生クラスSample2 using System; using System.Drawing; using System.Windows.Forms; public class Sample2 : Sample1 { Brush brush = new SolidBrush(Color.Black); public void helloworld() { g.DrawString("Hello, world!", this.Font, brush, 10, 10); } } なぜ表示されないのか分かる方いらしたら、ご教授願えないでしょうか。是非お願いします。