關於rxRichedit存成的RTF檔 |
答題得分者是:pceyes
|
jimlee
一般會員 發表:16 回覆:13 積分:5 註冊:2005-07-20 發送簡訊給我 |
|
pceyes
尊榮會員 發表:70 回覆:657 積分:1140 註冊:2003-03-13 發送簡訊給我 |
|
jimlee
一般會員 發表:16 回覆:13 積分:5 註冊:2005-07-20 發送簡訊給我 |
我做的是問題回報系統,
客戶並不希望回報給主管的是縮小的圖, 而是希望自己print-screen下來的圖在系統裡能完整呈現。 轉成jpeg的方式是?我ctrl v貼在rxrichedit時能變成jpeg的圖? 因為客戶貼圖的方式是: 1. print-screen→在rxrichedit上按ctrl v貼上 2. 把print-screen下來的圖貼到小畫家,然後圈起所要的區域按ctrl x→再到rxrichedit上按ctrl v貼上 能告知一下我要轉成jpeg的時間點是? 還是在rxrichedit存成rtf時,能將rxrichedit裡的圖像換成jpeg? 感謝回應。 ===================引 用 pceyes 文 章=================== 一般人在收到相片時,其實都太大了,要拉來拉去才看到全貌 1. 先縮小,站上有許多縮圖,內縮法,外縮法... 2. 轉成jpeg格式,也請找一下。 |
pceyes
尊榮會員 發表:70 回覆:657 積分:1140 註冊:2003-03-13 發送簡訊給我 |
你偷縮小,誰會知道(自由心証啦)
您可以用繪圖軟體試一下,畫面看的圖和列印的圖不同 所以如果是畫面上看的可以縮得很小,如果要列印當然要大一點,但是你可以取一個中間值,試試看如何可以接受就好了。 ===================引 用 jimlee 文 章=================== 我做的是問題回報系統, 客戶並不希望回報給主管的是縮小的圖, 而是希望自己print-screen下來的圖在系統裡能完整呈現。 轉成jpeg的方式是?我ctrl v貼在rxrichedit時能變成jpeg的圖? 因為客戶貼圖的方式是: 1. print-screen→在rxrichedit上按ctrl v貼上 1.5 Image1.Picture.Graphic.LoadFromClipboardFormat(...); 此時轉換後再丟回ClipBoard 2. 把print-screen下來的圖貼到小畫家,然後圈起所要的區域按ctrl x→再到rxrichedit上按ctrl v貼上 2.5 Image1.Picture.Graphic.LoadFromClipboardFormat(...); 此時轉換後再丟回ClipBoard 能告知一下我要轉成jpeg的時間點是? 就不相信沒辦法 還是在rxrichedit存成rtf時,能將rxrichedit裡的圖像換成jpeg? 此時很難 感謝回應。 ===================引 用 pceyes 文 章=================== 一般人在收到相片時,其實都太大了,要拉來拉去才看到全貌 1. 先縮小,站上有許多縮圖,內縮法,外縮法... 2. 轉成jpeg格式,也請找一下。
------
努力會更接近成功 |
jimlee
一般會員 發表:16 回覆:13 積分:5 註冊:2005-07-20 發送簡訊給我 |
感謝你提供的兩個方法,目前我想先試你第二個方法,
可能我理解的能力有限, 1.5 Image1.Picture.Graphic.LoadFromClipboardFormat(...); 此時轉換後再丟回ClipBoard 客戶按下print-screen鍵,截取的畫面就在剪貼簿了,我該怎麼截取轉換再丟到剪貼簿? 我先再試試,感謝你的解法。 ===================引 用 pceyes 文 章=================== 你偷縮小,誰會知道(自由心証啦) 您可以用繪圖軟體試一下,畫面看的圖和列印的圖不同 所以如果是畫面上看的可以縮得很小,如果要列印當然要大一點,但是你可以取一個中間值,試試看如何可以接受就好了。 ===================引 用 jimlee 文 章=================== 我做的是問題回報系統, 客戶並不希望回報給主管的是縮小的圖, 而是希望自己print-screen下來的圖在系統裡能完整呈現。 轉成jpeg的方式是?我ctrl v貼在rxrichedit時能變成jpeg的圖? 因為客戶貼圖的方式是: 1. print-screen→在rxrichedit上按ctrl v貼上 1.5 Image1.Picture.Graphic.LoadFromClipboardFormat(...); 此時轉換後再丟回ClipBoard 2. 把print-screen下來的圖貼到小畫家,然後圈起所要的區域按ctrl x→再到rxrichedit上按ctrl v貼上 2.5 Image1.Picture.Graphic.LoadFromClipboardFormat(...); 此時轉換後再丟回ClipBoard 能告知一下我要轉成jpeg的時間點是? 就不相信沒辦法 還是在rxrichedit存成rtf時,能將rxrichedit裡的圖像換成jpeg? 此時很難 感謝回應。 ===================引 用 pceyes 文 章=================== 一般人在收到相片時,其實都太大了,要拉來拉去才看到全貌 1. 先縮小,站上有許多縮圖,內縮法,外縮法... 2. 轉成jpeg格式,也請找一下。 |
pceyes
尊榮會員 發表:70 回覆:657 積分:1140 註冊:2003-03-13 發送簡訊給我 |
參考一下:
它取得剪貼簿的Bmp後,將它轉為jpeg格式 http://www.swissdelphicenter.ch/torry/showcode.php?id=874 ...convert a Bitmap to a JPEG and save it? [code delphi] uses Jpeg, ClipBrd; procedure TfrmMain.ConvertBMP2JPEG; // konvertiert ein Bitmap, z.B. die Grafik eines TCharts in ein JPEG // converts a bitmap, the graphic of a TChart for example, to a jpeg var jpgImg: TJPEGImage; begin // copy bitmap to clipboard chrtOutputSingle.CopyToClipboardBitmap; // get clipboard and load it to Image1 Image1.Picture.Bitmap.LoadFromClipboardFormat(cf_BitMap, ClipBoard.GetAsHandle(cf_Bitmap), 0); // create the jpeg-graphic jpgImg := TJPEGImage.Create; // assign the bitmap to the jpeg, this converts the bitmap jpgImg.Assign(Image1.Picture.Bitmap); // and save it to file jpgImg.SaveToFile('TChartExample.jpg'); end; [/code]
------
努力會更接近成功
編輯記錄
pceyes 重新編輯於 2008-09-18 22:24:39, 註解 無‧
|
pceyes
尊榮會員 發表:70 回覆:657 積分:1140 註冊:2003-03-13 發送簡訊給我 |
這篇更棒,把jpeg檔貼到剪簿上面去
...Copie/Paste a Bitmap to/from the clipboard? http://www.swissdelphicenter.ch/torry/showcode.php?id=1981 [code delphi] { In order to run this example you will need the GR32 Unit from the package http://www.g32.org/files/graphics32/graphics32-1_5_1.zip to run this example. } unit EG_ClipboardBitmap32; { Author William Egge. egge@eggcentric.com January 17, 2002 Compiles with ver 1.2 patch #1 of Graphics32 This unit will copy and paste Bitmap32 pixels to the clipboard and retain the alpha channel. The clipboard data will still work with regular paint programs because this unit adds a new format only for the alpha channel and is kept seperate from the regular bitmap storage. } interface uses ClipBrd, Windows, SysUtils, GR32; procedure CopyBitmap32ToClipboard(const Source: TBitmap32); procedure PasteBitmap32FromClipboard(const Dest: TBitmap32); function CanPasteBitmap32: Boolean; implementation const RegisterName = 'G32 Bitmap32 Alpha Channel'; GlobalUnlockBugErrorCode = ERROR_INVALID_PARAMETER; var FAlphaFormatHandle: Word = 0; procedure RaiseSysError; var ErrCode: LongWord; begin ErrCode := GetLastError(); if ErrCode <> NO_ERROR then raise Exception.Create(SysErrorMessage(ErrCode)); end; function GetAlphaFormatHandle: Word; begin if FAlphaFormatHandle = 0 then begin FAlphaFormatHandle := RegisterClipboardFormat(RegisterName); if FAlphaFormatHandle = 0 then RaiseSysError; end; Result := FAlphaFormatHandle; end; function CanPasteBitmap32: Boolean; begin Result := Clipboard.HasFormat(CF_BITMAP); end; procedure CopyBitmap32ToClipboard(const Source: TBitmap32); var H: HGLOBAL; Bytes: LongWord; P, Alpha: PByte; I: Integer; begin Clipboard.Assign(Source); if not OpenClipboard(0) then RaiseSysError else try Bytes := 4 (Source.Width * Source.Height); H := GlobalAlloc(GMEM_MOVEABLE and GMEM_DDESHARE, Bytes); if H = 0 then RaiseSysError; P := GlobalLock(H); if P = nil then RaiseSysError else try PLongWord(P)^ := Bytes - 4; Inc(P, 4); // Copy Alpha into Array Alpha := Pointer(Source.Bits); Inc(Alpha, 3); // Align with Alpha for I := 1 to (Source.Width * Source.Height) do begin P^ := Alpha^; Inc(Alpha, 4); Inc(P); end; finally if (not GlobalUnlock(H)) then if (GetLastError() <> GlobalUnlockBugErrorCode) then RaiseSysError; end; SetClipboardData(GetAlphaFormatHandle, H); finally if not CloseClipboard then RaiseSysError; end; end; procedure PasteBitmap32FromClipboard(const Dest: TBitmap32); var H: HGLOBAL; ClipAlpha, Alpha: PByte; I, Count, PixelCount: LongWord; begin if Clipboard.HasFormat(CF_BITMAP) then begin Dest.BeginUpdate; try Dest.Assign(Clipboard); if not OpenClipboard(0) then RaiseSysError else try H := GetClipboardData(GetAlphaFormatHandle); if H <> 0 then begin ClipAlpha := GlobalLock(H); if ClipAlpha = nil then RaiseSysError else try Alpha := Pointer(Dest.Bits); Inc(Alpha, 3); // Align with Alpha Count := PLongWord(ClipAlpha)^; Inc(ClipAlpha, 4); PixelCount := Dest.Width * Dest.Height; Assert(Count = PixelCount, 'Alpha Count does not match Bitmap pixel Count, PasteBitmap32FromClipboard(const Dest: TBitmap32);'); // Should not happen, but if it does then this is a safety catch. if Count > PixelCount then Count := PixelCount; for I := 1 to Count do begin Alpha^ := ClipAlpha^; Inc(Alpha, 4); Inc(ClipAlpha); end; finally if (not GlobalUnlock(H)) then if (GetLastError() <> GlobalUnlockBugErrorCode) then RaiseSysError; end; end; finally if not CloseClipboard then RaiseSysError; end; finally Dest.EndUpdate; Dest.Changed; end; end; end; end. // Example Call: {uses JPEG;} procedure TForm1.Button1Click(Sender: TObject); var bmp: TBitmap32; begin bmp := TBitmap32.Create; try bmp.LoadFromFile('C:\test.jpg'); CopyBitmap32ToClipboard(bmp); finally bmp.Free; end; end; [/code]
------
努力會更接近成功 |
pceyes
尊榮會員 發表:70 回覆:657 積分:1140 註冊:2003-03-13 發送簡訊給我 |
最後補強一下,偵測剪貼簿的變化
...get notified when the content of the clipboard changes? http://www.swissdelphicenter.ch/torry/showcode.php?id=1888 [code delphi] { An application can be notified of changes in the data stored in the Windows clipboard by registering itself as a Clipboard Viewer. Clipboard viewers use two API calls and several messages to communicate with the Clipboard viewer chain. SetClipboardViewer adds a window to the beginning of the chain and returns a handle to the next viewer in the chain. ChangeClipboardChain removes a window from the chain. When a clipboard change occurs, the first window in the clipboard viewer chain is notified via the WM_DrawClipboard message and must pass the message on to the next window. To do this, our application must store the next window along in the chain to forward messages to and also respond to the WM_ChangeCBChain message which is sent whenever any other clipboard viewer on the system is added or removed to ensure the next window along is valid. } unit Unit1; interface uses Windows, Messages, Forms, Classes, Controls, StdCtrls; type TForm1 = class(TForm) Button1: TButton; Button2: TButton; procedure Button1Click(Sender : TObject); procedure Button2Click(Sender : TObject); procedure FormCreate(Sender : TObject); procedure FormDestroy(Sender : TObject); private FNextClipboardViewer: HWND; procedure WMChangeCBChain(var Msg : TWMChangeCBChain); message WM_CHANGECBCHAIN; procedure WMDrawClipboard(var Msg : TWMDrawClipboard); message WM_DRAWCLIPBOARD; end; var Form1 : TForm1; implementation {$R *.DFM} procedure TForm1.FormCreate(Sender : TObject); begin { Initialize variable } FNextClipboardViewer := 0; end; procedure TForm1.Button1Click(Sender : TObject); begin if FNextClipboardViewer <> 0 then MessageBox(0, 'This window is already registered!', nil, 0) else { Add to clipboard chain } FNextClipboardViewer := SetClipboardViewer(Handle); end; procedure TForm1.Button2Click(Sender : TObject); begin { Remove from clipboard chain } ChangeClipboardChain(Handle, FNextClipboardViewer); FNextClipboardViewer := 0; end; procedure TForm1.WMChangeCBChain(var Msg : TWMChangeCBChain); begin inherited; { mark message as done } Msg.Result := 0; { the chain has changed } if Msg.Remove = FNextClipboardViewer then { The next window in the clipboard viewer chain had been removed. We recreate it. } FNextClipboardViewer := Msg.Next else { Inform the next window in the clipboard viewer chain } SendMessage(FNextClipboardViewer, WM_CHANGECBCHAIN, Msg.Remove, Msg.Next); end; procedure TForm1.WMDrawClipboard(var Msg : TWMDrawClipboard); begin inherited; { Clipboard content has changed } try MessageBox(0, 'Clipboard content has changed!', 'Clipboard Viewer', MB_ICONINFORMATION); finally { Inform the next window in the clipboard viewer chain } SendMessage(FNextClipboardViewer, WM_DRAWCLIPBOARD, 0, 0); end; end; procedure TForm1.FormDestroy(Sender : TObject); begin if FNextClipboardViewer <> 0 then begin { Remove from clipboard chain } ChangeClipboardChain(Handle, FNextClipboardViewer); FNextClipboardViewer := 0; end; end; end. [/code]
------
努力會更接近成功 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |