我用D6,当我执行:
  bmp :=TBitmap.Create;
  bmp.Assign(Image1.Picture.Bitmap);
时,Image1的图像没了.换用
  image2.Picture.Bitmap.Canvas.CopyRect(rectd,image1.Picture.Bitmap.Canvas,rects);
时也一样.可是以前在BCB5用得好好的呀.

解决方案 »

  1.   

    需要设置一下bmp的高度喝宽度吧。
    bmp.width := 100;
    bmp.Height := 1000;
      

  2.   

    var
      mBitmap:Tbitmap;
    begin
      mBitmap:=Tbitmap.create;
      mBitmap.loadfromfile('bmpfile.bmp');
      self.brush.bitmap:=Tbitmap;
    end;
      

  3.   

    这个BMP是DIB吗?假如是DIB的话,只能取得一个句柄,这个句柄要是被两个BMP拥有的话,可能会出问题。
      

  4.   

    设置了高宽都是一样的
    将IMAGE1的一部分COPY到IMAGE2,奇怪我以前用BCB5怎么就好好的?
    int x,y,w,h;
    TRect rect;     try {
            x = Form1->ResoxEdit->Text.ToInt();
         }
         catch (Exception &exception){
            x = 128;
          };
         try
          {
            y = Form1->ResoyEdit->Text.ToInt();      }
         catch (Exception &exception){
            y = 120;
         };
         TRect rdes(0,0,x,y);
         Image2->Width = x;
         Image2->Height = y;
         Image2->Canvas->Brush->Color = clWhite;
         Image2->Canvas->FillRect(rdes);   // clear to white
         w = Image1->Picture->Width;
         h = Image1->Picture->Height;
         if (mouse.x==0 && mouse.y==0) {
             rect.Left = ((w-x)/2 >=0) ? ((w-x)/2) : 0;
             rect.Top = ((h-y)/2 >=0) ? ((h-y)/2) : 0;
             }
         else {
             rect.Left = (mouse.x*w/Image1->Width-x/2 >=0) ? (mouse.x*w/Image1->Width-x/2) : 0;
             rect.Top = (mouse.y*h/Image1->Height-y/2 >=0) ? (mouse.y*h/Image1->Height-y/2) : 0;
             }
         rect.Right = rect.Left + x;
         rect.Bottom = rect.Top + y;
         Image2->Canvas->CopyRect(rdes,Image1->Canvas,rect);
         Form1->PreviewImage->Width = x;
         Form1->PreviewImage->Height = y;
         Form1->PreviewImage->Canvas->CopyRect(rdes,Image2->Canvas,rdes);
      

  5.   

    var
    bmp:tbitmap;
    begin
    bmp:=Image1.Picture.Bitmap;
    end;
      

  6.   

    弄来弄去总是不行.只是复制了图像,Image1的图像就没了.
      

  7.   

    啊.Image1里放的是JPG图像,换成BMP就行了.
    这也奇怪.
      

  8.   

    啊?如果是这样那自然就是确实如此~~~jpeg :=TJPEGImage.Create;
    jpeg.Assign(Image1.Picture.Graphic);或者这样bmp:=TBitmap.Create;
    bmp.Assign(Image1.Picture.Graphic);后者进行了格式转换直接用Image1.Picture.Bitmap,会因为调用GetBitmap破坏图像数据指针!