全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:1226
推到 Plurk!
推到 Facebook!

讀取某BMP圖形的pixel值後,再重新顯示圖形,圖形顯示不完整

答題得分者是:malanlk
hct47
一般會員


發表:34
回覆:15
積分:9
註冊:2004-04-23

發送簡訊給我
#1 引用回覆 回覆 發表時間:2005-08-24 17:05:04 IP:210.202.xxx.xxx 未訂閱
Dear all:       如下圖,左邊是我叫出顯示的圖形,右邊是我處理過的圖形(將右邊圖形的每個pixel值取出,再丟到另一個TBitmap對應的pixel值),結果右邊的圖形無法完整顯示,不知道哪邊是出問題了?我用小一點的圖沒問題,但是大一點的圖就會有這樣的問題,可以請大家幫我看一下程式哪裡錯了嗎?
 
 unit Unit1;    interface    uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls, ExtDlgs;
const arcou = 500;
      maxp = 2;
type Tpixelrecord = record
     pixelC : array [0..maxp] of array [0..arcou] of array [0..arcou] of Longword;
end;
type TSelectpic = record
     Name         : string[100];
     SelectPic    : array [0..maxp] of TBitmap;
     SelectPic1   : array [0..maxp] of Timage;
     Pic          : array [0..maxp] of string;
     status       : array [0..maxp] of byte;
     //definel      : array [0..maxp] of string[str50];
     //definel      : array [0..maxp] of string;
     //define       : array [0..maxp] of array[0..5] of string[str10];
     //define       : array [0..maxp] of array[0..5] of string;
     definecoun   : array [0..maxp] of integer;
     picw         : array [0..maxp] of Longword;
     pich         : array [0..maxp] of Longword;
     totalp       : integer;
end;
type
  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    Image1: TImage;
    Image2: TImage;
    OpenPictureDialog1: TOpenPictureDialog;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
  pixco:Tpixelrecord;
  Selpic:TSelectpic;
    { Public declarations }
  end;    var
  Form1: TForm1;    implementation    {$R *.dfm}    procedure TForm1.Button1Click(Sender: TObject);
var i,j:integer;
begin         if Openpicturedialog1.Execute then
     begin
         SelPic.SelectPic[0]:=TBitmap.Create;
         Selpic.SelectPic[0].LoadFromFile(OpenPictureDialog1.FileName);
         Selpic.Pic[0]:=OpenPictureDialog1.FileName;
         image1.Canvas.StretchDraw(Rect(0,0,image1.Width,image1.Height),
                                   Selpic.SelectPic[0]);             selpic.picw[0]:=selpic.SelectPic[0].Height;
         selpic.pich[0]:=selpic.selectPic[0].Width;             for i:=0 to selpic.picw[0] do
         begin
           for j:=0 to selpic.pich[0] do
           begin
               pixco.pixelC[0][i][j]:=selpic.SelectPic[0].Canvas.Pixels[i,j];
           end;
         end;
   end;
        // SelPic.SelectPic[picn].Free;    end;    procedure TForm1.Button2Click(Sender: TObject);
var j,k:integer;
begin
   selpic.SelectPic[1]:=Tbitmap.Create;
   selpic.SelectPic[1].Height:=selpic.SelectPic[0].Height;
   selpic.SelectPic[1].Width:=selpic.SelectPic[0].Width;
   for j:=0 to selpic.picw[0] do
   begin
       for k:=0 to selpic.pich[0] do
       begin
               selpic.SelectPic[1].Canvas.Pixels[j,k]:=pixco.pixelC[0][j][k];
       end;
   end;       image2.Canvas.StretchDraw(Rect(0,0,image1.width,image1.height),selpic.SelectPic[1]);
end;    end.
   
malanlk
尊榮會員


發表:20
回覆:694
積分:577
註冊:2004-04-19

發送簡訊給我
#2 引用回覆 回覆 發表時間:2005-08-24 17:30:00 IP:203.69.xxx.xxx 未訂閱
selpic.picw[0]:=selpic.SelectPic[0].Height; selpic.pich[0]:=selpic.selectPic[0].Width; 這兩行搞錯了
系統時間:2024-05-19 16:11:37
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!