How to paint directly on canvas?
How to paint directly on canvas?
How to paint directly on canvas?
If I use the classic painting, so I always line snaps to the cursor.
Currently I use a procedure to insert the RVE TImage and then paint it.
This is not the optimal solution and do not know how to calculate the size of the embedded TImage from the cursor position to the right and bottom of the page.
Can you give me a link to the demo, which is solved RVE painting on canvas?
Thank you very much.
If I use the classic painting, so I always line snaps to the cursor.
Currently I use a procedure to insert the RVE TImage and then paint it.
This is not the optimal solution and do not know how to calculate the size of the embedded TImage from the cursor position to the right and bottom of the page.
Can you give me a link to the demo, which is solved RVE painting on canvas?
Thank you very much.
-
- Site Admin
- Posts: 17569
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Thank you, but this does not solve my problem.Sergey Tkachenko wrote:See Demos\*\Assorted\Custom Draw\CustomDraw\
I need to manually draw Canvas RVE.
The solution with TImage I took only an option if you will not draw directly on Cnavas RVE.
I do not know how to incorporate position location.
I used method:
Code: Select all
var
Draw: boolean;
begin
Image1.Parent: = RVE;
and until then I just cut a section drawn in image2:
Code: Select all
procedure TEditor.ScanImage;
var
XIndex, YIndex, xmin, xmax, ymin, ymax: integer;
DstRect, SrcRect: TRect;
bmp: TBitmap;
begin
Xmin: = image1.ClientWidth;
Ymin: = image1.ClientHeight;
Xmax: = 0;
Ymax: = 0;
YIndex for: = 0 to image1.ClientHeight - 1 to
XIndex for: = 0 to image1.ClientWidth - 1 to
if image1.Canvas.Pixels [XIndex, YIndex] <>
image1.Canvas.Brush.Color then
begin
if XIndex <xmin then
Xmin: = XIndex;
if YIndex <ymin then
Ymin: = YIndex;
if XIndex> xMax then
Xmax: = XIndex;
if YIndex> ymax then
Ymax: = YIndex;
end;
bmp: = TBitmap.Create;
try
Bmp.PixelFormat: = pf32bit;
Bmp.Width: = (Xmax-Xmin) +2;
Bmp.Height: = (ymax-ymin) +2;
BMP.Transparent: = True;
bmp.TransparentColor: = image1.Canvas.Brush.Color;
bmp.TransparentMode: = tmAuto;
bmp.Canvas.CopyMode: = cmSrcCopy;
DstRect: = Rect (0, 0, bmp.Width, bmp.height);
SrcRect: = Rect (xmin -1, ymin -1, +2 Xmax, ymax +2);
bmp.Canvas.CopyRect (DstRect, image1.Canvas, SrcRect);
Image2.Picture.Bitmap.Assign (bmp);
bmp.SaveToFile ('C:\\test.bmp');
??? RVE add Image BMP ???
finally
Bmp.Free;
end;
end;
procedure TEditor.RVEMouseMove (Sender: TObject;
Shift: TShiftState, X, Y: Integer);
begin
if draw = True then image1.canvas.lineto (x, y);
end;
procedure TEditor.RVEMouseUp (Sender: TObject;
Button: TMouseButton; Shift: TShiftState, X, Y: Integer);
begin
draw: = false;
ScanImage;
end;
-
- Site Admin
- Posts: 17569
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Sorry, I do not understand where do you want to draw.
If you want to draw on TRichViewEdit canvas, you can use OnPaint event.
If you want to implement a custom drawn item, probably drawing on a bitmap/metafile and inserting it in TRichViewEdit is the best solution. Or you can insert TPaintBox component.
If you want to draw on TRichViewEdit canvas, you can use OnPaint event.
If you want to implement a custom drawn item, probably drawing on a bitmap/metafile and inserting it in TRichViewEdit is the best solution. Or you can insert TPaintBox component.
Hello
I'm sorry but just because I do not know how to draw on the canvas SRichViewEdit so I wanted to resolve the insertion of TImage.
If there is the possibility to insert TPaintBox then how do I draw the image into ScaleRichView.
Please demo if possible.
If possible, the fastest alternative.
thank you very much
I'm sorry but just because I do not know how to draw on the canvas SRichViewEdit so I wanted to resolve the insertion of TImage.
If there is the possibility to insert TPaintBox then how do I draw the image into ScaleRichView.
Please demo if possible.
If possible, the fastest alternative.
thank you very much
-
- Site Admin
- Posts: 17569
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
-
- Site Admin
- Posts: 17569
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
-
- Site Admin
- Posts: 17569
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
After studying your code, I am not sure that I understand what you want to draw.
1) Why all this complication in ScanImage? Why don't you just insert an image from Image1 in SRichViewEdit?
2) To make sure, do you want to work with TSRichViewEdit (i.e. ScaleRichView) or TRichViewEdit?
3) As I understand, you want to draw a line to the mouse pointer then a mouse button is pressed. Ok, the line end at the mouse pointer, but where does it start?
4) What if you inserted several such images?
PS: unfortunately, TSRichViewEdit does not support transparency in images (unlike TRichViewEdit).
1) Why all this complication in ScanImage? Why don't you just insert an image from Image1 in SRichViewEdit?
2) To make sure, do you want to work with TSRichViewEdit (i.e. ScaleRichView) or TRichViewEdit?
3) As I understand, you want to draw a line to the mouse pointer then a mouse button is pressed. Ok, the line end at the mouse pointer, but where does it start?
4) What if you inserted several such images?
PS: unfortunately, TSRichViewEdit does not support transparency in images (unlike TRichViewEdit).
-
- Site Admin
- Posts: 17569
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
There is a difference if you want to draw inside the item rectangle or in arbitrary place of the editor canvas. The former is easier: you can use pictures or paint-boxes.
I created a simple demo for inserting figures in TSRichViewEdit:
http://www.trichview.com/support/files/srvfigures.zip
This demo requires installed SRVControls.
It shows 3 ways of adding shapes in the editor:
1) paint-boxes (TSRVPaintBox)
2) images - bitmaps
3) images - metafiles
I created a simple demo for inserting figures in TSRichViewEdit:
http://www.trichview.com/support/files/srvfigures.zip
This demo requires installed SRVControls.
It shows 3 ways of adding shapes in the editor:
1) paint-boxes (TSRVPaintBox)
2) images - bitmaps
3) images - metafiles