![]() |
| ||
|
|
Новости |
Поиск |
FAQ |
Статьи |
Книги |
Новости VCL
| | Форумы ЧАТ |
Орешник |
|
| |||
| |||
« предыдущая ветвь | форум | следующая ветвь »
Графика в TRichEdit [D7]
ivane © (2005-01-29 12:18:00)Есть RichEdit. Нужно в середине текста поместить картинку. Как или с помощью чего это сделать?
Eraser (2005-01-31 16:13:00) [1]fess ©
Весь интернет заполнин этим примером, но что самое удивительное- он не работает ;-)))
ivane
http://sourceforge.net/projects/jvcl/
fess (2005-01-30 16:04:00) [2]Используй библиотеку RxLib и компонент RxRichEdit.
Функция для рисунка копирования рисунка в формат rtf:
function TMainFormInput.BitmapToRTF(pict: TBitmap): string;
var
bi, bb, rtf: string;
bis, bbs: Cardinal;
achar: ShortString;
hexpict: string;
I: Integer;
begin
GetDIBSizes(pict.Handle, bis, bbs);
SetLength(bi, bis);
SetLength(bb, bbs);
GetDIB(pict.Handle, pict.Palette, PChar(bi)^, PChar(bb)^);
rtf := '{\rtf1 {\pict\dibitmap ';
SetLength(hexpict, (Length(bb) + Length(bi)) * 2);
I := 2;
for bis := 1 to Length(bi) do
begin
achar := Format('%x', [Integer(bi[bis])]);
if Length(achar) = 1 then
achar := '0' + achar;
hexpict[I - 1] := achar[1];
hexpict[I] := achar[2];
Inc(I, 2);
end;
for bbs := 1 to Length(bb) do
begin
achar := Format('%x', [Integer(bb[bbs])]);
if Length(achar) = 1 then
achar := '0' + achar;
hexpict[I - 1] := achar[1];
hexpict[I] := achar[2];
Inc(I, 2);
end;
rtf := rtf + hexpict + ' }}';
Result := rtf;
end;
Пример использования
...
SS: TStringStream;
BMP: TBitMap;
begin
...
BMP := TBitMap.Create;
BMP.LoadFromFile('C:\temp\tests\data\' + dm.q2.FieldByName('Id_Question').AsString + '.bmp');
SS := TStringStream.Create(BitmapToRTF(BMP));
RichEdit1.PlainText := False;
RichEdit1.StreamMode := [smSelection];
RichEdit1.Lines.LoadFromStream(SS);
RichEdit1.StreamMode := [];
SS.Free;
BMP.Free;
end;