trichview.support
How to paste bitmap without bigsize #2 |
Author |
Message |
Ibrahim Kutluay |
Posted: 04/01/2005 11:40:20 Dear Sergei I have tried the your png proposal but the blob size still very big. So have switch the direction and dig some code. i m now using the dbrichedit controls "onpaste" method. here is the code. the code catches the paste event and if cilipboard has a bitmap then it takes that bitmap a tbitmap and copy it from that bitmap to a jpeg file, then after this the component insert (import) that file in to richedit. So.. if i remove the "abort ;" comand it is pasting the picture two times (normal coz im inserting and the caontrol pasting)... but the other format pasting is giving a stack overflow error. I have good propsal for that... can u add a new property like that "convert_bitmaps_to_png_onpaste" (or jpg) This can be good. ------------------------------------------------------------------------------------------------------------------------------- procedure TFrmNotes.RichPaste(Sender: TCustomRichViewEdit; var DoDefault: Boolean); var V: Integer; JPEG: TJPEGImage; Bitmap: TBitmap; pic:Tpicture; gr: TGraphic; begin If Clipboard.HasFormat(CF_BITMAP) then Begin JPEG := TJPEGImage.Create; Bitmap := TBitmap.Create; try Bitmap.LoadFromClipBoardFormat(cf_BitMap,ClipBoard.GetAsHandle(cf_Bitmap),0); JPEG.Assign(Bitmap); JPEG.SaveToFile('deneme.jpg'); finally JPEG.Free; Bitmap.Free; end; // try try pic := TPicture.Create; try pic.LoadFromFile('Deneme.jpg'); gr := RV_CreateGraphics(TGraphicClass(pic.Graphic.ClassType)); gr.Assign(pic.Graphic); finally pic.Free; end; if gr<>nil then Rich.InsertPicture('',gr,rvvaBaseLine); except Application.MessageBox(PChar('Cannot read picture from file '+OpenDialog.FileName), 'Error',MB_OK or MB_ICONSTOP); gr.Free; end; Abort; End else // If Clipboard.HasFormat(CF_TEXT) Then Begin Rich.Paste; // Abort; End; // v := 0; // Rich.RVData.EnumItems(EnumItemsProc, v, ''); end; --------------------------------------------------------------------------------------------------------------------------------------------- |
Powered by ABC Amber Outlook Express Converter