Hi,
I would like to take some existing JPEG image files and overlay the filename and a 'Title' as text on them.
Can I do this using GDI, just by displaying the file on some sort of canvas, drawing some text on that canvas and then saving the image back to a file?
I see we have TImage and TImageEditor using FreeImage in the Enterprise Edition .... is this the way to go?
Any general thoughts or simple example code would be much appreciated.
..... I've just researched the Samples folder and there are some useful Image display and edit examples. I should have looked there first .....
Not seeing any text drawing though?
Thanks
Chris
In order for this site to work correctly we need to store a small file (called a cookie) on your computer. Most every site in the world does this, however since the 25th of May 2011, by law we have to get your permission first. Please abandon the forum if you disagree.
Para que este foro funcione correctamente es necesario guardar un pequeño fichero (llamado cookie) en su ordenador. La mayoría de los sitios de Internet lo hacen, no obstante desde el 25 de Marzo de 2011 y por ley, necesitamos de su permiso con antelación. Abandone este foro si no está conforme.
Para que este foro funcione correctamente es necesario guardar un pequeño fichero (llamado cookie) en su ordenador. La mayoría de los sitios de Internet lo hacen, no obstante desde el 25 de Marzo de 2011 y por ley, necesitamos de su permiso con antelación. Abandone este foro si no está conforme.
Add some text to JPEG images .....
-
- Mensajes: 384
- Registrado: Mar May 01, 2007 5:49 pm
- ignacio
- Site Admin
- Mensajes: 9252
- Registrado: Lun Abr 06, 2015 8:00 pm
- Ubicación: Madrid, Spain
- Contactar:
Re: Add some text to JPEG images .....
Hello,
If you just want to put the text on top of the image you can use a label with its property lTransparent set to true. Another way is to use its OnPainted event. Something like this:
In case you need to modify the image file adding some text information, I'm afraid you must deal with some 'C' code. This is the way to go:
- Create a compatible DC:
- Create a compatible Bitmap on memory with identical size of the original bitmap
- Copy (Bitblt function) the original bitmap to the compatible Bitmap
- Print the text on the compatilbe DC
- Save the compatible bitmap to file
If you need help on this please try to prototype the function you will need. Something like this:
And we will give a budge for that function.
BTW you may try to use the event OnPainted and then use the:
Regards,
If you just want to put the text on top of the image you can use a label with its property lTransparent set to true. Another way is to use its OnPainted event. Something like this:
Código: Seleccionar todo
METHOD Image1Painted( oSender, hDC, cPaintStruct ) CLASS TForm1
LOCAL oCanvas AS CLASS TCanvas
oCanvas := TCanvas():NewFromDC( hDC )
oCanvas:TextOut(0,0, "Hello", 500, clBlack )
oCanvas:End()
RETURN Nil
- Create a compatible DC:
- Create a compatible Bitmap on memory with identical size of the original bitmap
- Copy (Bitblt function) the original bitmap to the compatible Bitmap
- Print the text on the compatilbe DC
- Save the compatible bitmap to file
If you need help on this please try to prototype the function you will need. Something like this:
Código: Seleccionar todo
PutTextOnBitmap( cSourceFile, cTargetFile, nX, nY, cText, nColor )
BTW you may try to use the event OnPainted and then use the:
Código: Seleccionar todo
XA_CaptureBitmap( <hWnd>, [<aRect>] | [<nLeft>, <nTop>, <nRight>, <nBottom>] ) --> hBitmap
-
- Mensajes: 384
- Registrado: Mar May 01, 2007 5:49 pm
Re: Add some text to JPEG images .....
Hi Ignacio,
Thank you for your comprehensive reply.
Its the second example, the images are high resolution photos in .JPG files. I need to add the text to them and then re-save them at the same resolution.
I will work on your second example and see how far I get and then ask for more help.
I'm glad to see you released 5.0 a few days ago.
I have installed it and taken a quick look at some of the extra features but am continuing with 4.X for a little longer as I have a few projects which need to be done quickly.
I'm sure I will be back!
Regards
Chris
Thank you for your comprehensive reply.
Its the second example, the images are high resolution photos in .JPG files. I need to add the text to them and then re-save them at the same resolution.
I will work on your second example and see how far I get and then ask for more help.
I'm glad to see you released 5.0 a few days ago.
I have installed it and taken a quick look at some of the extra features but am continuing with 4.X for a little longer as I have a few projects which need to be done quickly.
I'm sure I will be back!
Regards
Chris