PDA

View Full Version : Copy the ICImagingControl-Display to a canvas



Peter Bircher
March 11, 2004, 16:07:36
Hello,

I would like to copy the current a display (Picture) of the ICImagingControl to a Canvas in Delphi.
I tried to use Windows API funktions but I failed. I don't know exactly what I made wrong.

Does anybody have a Delphi example that works? It would be very helpful!

Thanks!

Stefan Geissler
March 11, 2004, 16:45:12
Peter,

If you could send a Delphi 6 project with IC Imaging Control and a "Canvas" to support at imagingcontrol dot com, i can try to figure this out. As i answered in the other thread, i have no Delphi knowledge, so i need some more time.

May be, you could use this code:


procedure TForm1.OnImageAvailable(Sender: TObject; BufferIndex: Integer);
var
hDIB : HGLOBAL;
pPixel : PCHAR;
pDIB : PCHAR;
bitmapinfo : Windows.BITMAPINFO;

begin
ICImagingControl1.ImageBuffers.Item[BufferIndex].Lock();
hDIB := ICImagingControl1.ImageBuffers.Item[BufferIndex].GetDib();
// Get the BITMAPINFO of the DIB
pDIB := GlobalLock(hDIB);
Move( pDIB^, bitmapinfo, sizeof(Windows.BITMAPINFO));
// Get the pointer to the Bitmapdata of the DIB
pPixel := pDIB + sizeof(bitmapinfo)-4;


// Stretch the DIB in the TImage.Picture. The DIB is resized
// to the size of the TImage object. The DIB is upside down,
// therefore, it must be mirrored in the StretchDIBits call.
// Refer to Windows GDI / Windows API
SetStretchBltMode(Image1.Picture.Bitmap.Canvas.Han dle,COLORONCOLOR);
StretchDIBits( Image1.Picture.Bitmap.Canvas.Handle,
0,0,
Image1.Width,
Image1.Height,
0,bitmapinfo.bmiHeader.biHeight,
bitmapinfo.bmiHeader.biWidth,
-bitmapinfo.bmiHeader.biHeight,
pPixel,
bitmapinfo,
DIB_RGB_COLORS,
SRCCOPY);

// Redraw the TImage
Image1.Refresh();

// Very important: unlock and free the allocated memory!!
GlobalUnlock( hDIB );
GlobalFree( hDIB );

// Now, unlock the buffer, so it can be used again.
ICImagingControl1.ImageBuffers.Item[BufferIndex].UnLock();

// The Frame should now be in the TImage.Picture object and can
// be used.
end;

Peter Bircher
March 17, 2004, 17:29:47
Hello,

Thanks for the Delphi example. It works!

Now I have an additional question: Is it also possible to copy just the display to the canvas (without the overlay bitmap)? In my case I can not disable the overlay bitmap bevore I copy the display.

Thank you.

Best regards
Peter Bircher

Stefan Geissler
March 18, 2004, 08:43:40
Peter,

This is not possible.

pierre2nice
August 8, 2012, 13:33:03
Google translation

Hello Peter

I use [B] Delphi6 [/ B] staff
I have not managed to display an image in a [B] TImage [/ B], I have no error at program startup.

I am not a computer expert, just an enthusiast, if you can detail a little use of the example set by Stephane srait this great!

cordially

Pierre (Peter !)
Nice (06) France

pierre2nice
December 31, 2012, 16:58:55
bonjour

J'essaie d'utiliser la possibilité de faire une mire sur ICImagingControl avec la fonctionnalité OverlayBitmap;

A l'exemple donné, j'ai ajouté la ligne en gras.
Cela fontionne, mais il est impossible d'effacer les dessins entre les images, je n'ai pas trouvé de fonction * ce sujet !!!
voir la ligne en gras ou les verticales se dessinent bien mais sont memorisées * l'affichage .
Mon code :
procedure TForm1.ICImagingControl1ImageAvailable(Sender: TObject;
BufferIndex: Integer);
var Buf : ImageBuffer;
ob : OverlayBitmap;
begin
try
if ICImagingControl1.LiveVideoRunning = True then
begin
//ICImagingControl1.OverlayBitmap.ReleaseDC(0);
//Buf := ICImagingControl1.ImageBuffers.Item[1];
// Buf.SaveImage('RGB24.bmp');
ob := ICImagingControl1.OverlayBitmap;
ob.Enable:=true;
ob.DrawText (RGB(255, 0, 255), 10, 10, 'IC Imaging Control 3.0');
ob.DrawLine (RGB(255, 0, 255),10,10,200,10);
ob.DrawLine (RGB(255, 0, 255),retx*2,0,rETX*2,800);
// RetX est une valeur qui change pour des coordonnées X différentes
end;

Merci pour votre aide.

Cdt
Pierre

Stefan Geissler
January 2, 2013, 09:55:08
Piere

I am very sorry, but I do not speak French language.

However, if you want to delete a drawing, you must draw it again using the drop out color:

http://www.imagingcontrol.com/en_US/support/documentation/activex/prop_descOverlayBitmap_DropOutColor.htm

legatobd
March 25, 2013, 17:13:58
Now I have an additional question: Is it also possible to copy just the display to the canvas (without the overlay bitmap)? In my case I can not disable the overlay bitmap bevore I copy the display.

Stefan Geissler
March 27, 2013, 09:58:24
Hello

Yes, you can do this. Simply use the overbitmap in the Display path only, then it is shown on screen, but it is not in memory. Please refer to http://www.imagingcontrol.com/en_US/support/documentation/activex/prop_descOverlayBitmap_PathPosition.htm