[轉檔]請問關於.RTF檔轉成.JPG檔 |
尚未結案
|
SCBT
一般會員 發表:2 回覆:3 積分:1 註冊:2004-02-05 發送簡訊給我 |
|
hagar
版主 發表:143 回覆:4056 積分:4445 註冊:2002-04-14 發送簡訊給我 |
|
andychang1690
資深會員 發表:20 回覆:694 積分:442 註冊:2003-03-14 發送簡訊給我 |
程式倒不大,短短幾十行而已,可惜我只會C++Builder
看那位大大能翻成Delphi,例子中是存於Image中:
Graphics::TBitmap *newBitmap; newBitmap = new Graphics::TBitmap(); HDC ScreenDC; TPoint REOrg; try { Image1->Picture->Graphic=newBitmap; Image1->Picture->Graphic->Width=RichEdit1->ClientWidth; Image1->Picture->Graphic->Height=RichEdit1->ClientHeight; REOrg=RichEdit1->ClientToScreen(Point(0,0)); ScreenDC=GetDC(0); try { BitBlt(Image1->Picture->Bitmap->Canvas->Handle,0,0,RichEdit1->ClientWidth,RichEdit1->ClientHeight,ScreenDC,REOrg.x, REOrg.y, SRCCOPY); } __finally { ReleaseDC(0, ScreenDC); } } __finally { newBitmap->Free(); }Andy Chang
------
Andy Chang |
SCBT
一般會員 發表:2 回覆:3 積分:1 註冊:2004-02-05 發送簡訊給我 |
小弟我太肉腳了剛學Delphi,又是自學的對於下面的程式中的
procedure RTFtoBitmap(cFileName: string; AParentWin: HWND; nWidth, nHeight:integer; var bm: TBitmap);
這個procedure RTFtoBitmap不知道怎麼使用,例如裡面的AParentWin: HWND跟 var bm: TBitmap要傳入甚麼值!
請高手能指導我一下,謝謝!!
----------------------------------------------------------------
uses ... , RichEdit; function PixelsToTwipsH(hDC: THandle; nPixels: integer): integer;
var
nPixelsPerInch: double;
begin
nPixelsPerInch := GetDeviceCaps(hDC, LOGPIXELSX);
Result := Round((1440 / nPixelsPerInch) * nPixels);
end; function PixelsToTwipsV(hDC: THandle; nPixels: integer): integer;
var
nPixelsPerInch: double;
begin
nPixelsPerInch := GetDeviceCaps(hDC, LOGPIXELSY);
Result := Round((1440 / nPixelsPerInch) * nPixels);
end; // load a rich text file into a bitmap of desired width and height procedure RTFtoBitmap(cFileName: string; AParentWin: HWND; nWidth, nHeight:
integer; var bm: TBitmap);
var
fmtRange: TFormatRange;
red: TRichEdit;
begin
if not Assigned(bm) then bm := TBitmap.Create; try
bm.Width := nWidth;
bm.Height := nHeight; red := TRichEdit.CreateParented(AParentWin); // gotta have a parent try
red.Lines.LoadFromFile(cFileName); fmtRange.hdc := bm.Canvas.Handle;
fmtRange.hdcTarget := bm.Canvas.Handle;
fmtRange.rc := Rect(0, 0,
PixelsToTwipsH(fmtRange.hdc, nWidth),
PixelsToTwipsV(fmtRange.hdc, nHeight));
fmtRange.rcPage := fmtRange.rc;
fmtRange.chrg.cpMin := 0;
fmtRange.chrg.cpMax := -1; with red do
begin
Perform(EM_FORMATRANGE, Integer(true), Integer(@fmtRange));
Perform(EM_FORMATRANGE, Integer(true), 0);
end;
finally
red.Free;
end;
except end; // error handling here
end;
|
hagar
版主 發表:143 回覆:4056 積分:4445 註冊:2002-04-14 發送簡訊給我 |
|
SCBT
一般會員 發表:2 回覆:3 積分:1 註冊:2004-02-05 發送簡訊給我 |
|
adonis
高階會員 發表:140 回覆:258 積分:159 註冊:2002-04-15 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |