Where can I find an image watermark control for Delphi? - delphi

Is there a good image watermark control for Delphi? It would be nice if it could receive both text and images to insert in a base photo.
I would also prefer it was free.

I couldn't find any pre-packaged controls. But watermarking is not very hard at all. All you simply need to do is draw an image on top of another image with the use of alpha blending. This site has a whole section on alpha blending in Delphi. They provide links to graphics libraries which have implemented it.
However if you're using Delphi.NET, and can access the relevant classes in the framework, there is an easier way using only framework methods.

Take a look at Graphics32 together with GraphicEX.
Or see if PascalMagick does the trick.

Related

how to manipulate graphics created with Adobe Animate CC?

So I have created some fancy graphics with Adobe Animate (HTML CANVAS)and added some animation as well. Is there a way to manipulate (or simply get) the Javascript code that generated these graphics? Say I want to use these same graphics in another project. How to extract that code? The generated code is not just simple CreateJS code. It is very tight to the Animate framework.
The code is in fact just plain CreateJS (EaselJS) code. In your generated lib file, you can see all the Graphic instructions for each Shape. For Animate, it uses a "compressed" format by default (which you can actually see in the docs). Since 95% of developers don't care what the exported graphics look like, so it uses a custom compression format to reduce the amount of code that is generated, which results in a much smaller filesize.
You can easily pop into the publish settings, and under "Advanced" turn off the "Compact Shapes" option, which will give you typical lineTo().moveTo().drawRect() commands again.
Hope that helps!

CGPathRef and PDF

It there a way to draw a complex shape with an application like CorelDraw or Adobe Flash, etc, save it or export it as a PDF and then open it with Core Graphics in iOS.
The idea is, to draw a shape, a vector, with CorelDraw - for example, and it is just the path. No color or fill. And then be able to open it directly by Core Graphics, add it as a CGPath to the context, and then be able to manipulate it, like fill it with solid color or gradient, or patterns.
The bottom line is, I am looking for a way to draw a complex shape in a user-friendly environment, like Corel or Flash, and export it, as a vactor, which can be manipulated in Core Graphics. And suggestions or help is really appreicated.
Thanks.
SVGKit doesn't work the exact same as I need either. Although I should say it is nicely done. There are also other resources, that I found and I'll leave them here for future references, if anyone stops by this post and is looking for a solution.
Converting SVG Paths to Objective-C Paths Good for simple paths; strokes and fills can be manipulated later by using protocols. Complex paths get mixed up.
SVGKit Good for creating images and animate them later through the course of the program. However, strokes, fills, paths can not be manipulated.
Opacity You can export as source code, hence you have more control over strokes, paths, and fills. As the path gets more complex, it is harder to manage the code manually. The other problem is by the time of export, the program adds resolution-dependent codes. It can be a pain to go through about 300+ lines of code to fix it so that it is not resolution dependent. By the final product wouldn't be mixed up, and can be manipulated by protocols. Layers are CGLayers, not CALayers.
If, as you say, you've got PDF files (from Corel, or another app), you can display them using CoreGraphics.
Take a look at the:
CGPDFDocument class
CGPDFPage class
Then, there is a CGContextDrawPDFPage function, that you can use to draw a PDF pages in a given graphic context, typically in the drawLayer: inContext: method of a UIView subclass.
There isn't really a built-in way to load CGPaths from files but you might want to take a look at SVGKit. Pretty much every modern vector drawing app can produce SVG files.

Resizing an image in Delphi XE

I got a jpeg image in which is 1020x780, I am trying to resize this to 111x85 (which is in proportion) but it comes out pixelated.
I am tried just
a) Assign the image to a TImage component and set the Scaled/Resize property.
b) The resize code here http://www.delphigroups.info/2/4/313095.html
c) The resize code here http://www.swissdelphicenter.ch/torry/showcode.php?id=1896
However they all come out pixelated.
If I resize in Photoshop then it comes out nice. Getting it THAT good would be ideal, however I know they spent a lot of time/code into resize so something even halfway between would be great.
Any suggestions?
Have a look at Graphics32 library. It implements various image resampling and transformation algorithms for 32-bit bitmaps.
In my blog I talk about resize images using/implementing antialiasing.
Read the article and test the code here. It's writed in Spanish but you can use authomatic translate. In any case you can read only the code.
See the difference of apply and not apply the code:
The code work with BMP, but you can convert the image first and apply it.
Instead of using the built-in TImage for scaling, you could use an external library or component, e.g. ImageMagick or some off-the-shelf component. There exists at least one Pascal wrapper for ImageMagick
http://wiki.freepascal.org/PascalMagick)
, but I've never used it myself.
I have successfully used HiComponents ImageEn library to resize an image down to approx 250 pixels. It was a while ago, but I recall that the results were quite pleasing. http://www.hicomponents.com/main/products/products-imageenvcl - it's free now, and well worth a look if you're doing any graphics programming in Delphi.

How I can detect the background of an image programmatically?

I need to develop a software that selects a face from a photo where the background is a plain color (green, like in the movies).
Then we want to compose that selection with another background image, this part is easy with many libraries. But I don't know how can I do the selection? Can you give some links or libraries to investigate? I can do this project with any language of my choose, so examples or links in any language are welcome.
Ok, what you are trying to do is called chroma key. Like you say, it used a lot in the movies with a blue/green screen. On windows its actually pretty easy to do because its built into windows as part of GDI+ (or on C#, I think its just called the Graphics class).
I dont have any sample code handy, but the process is pretty straight forward:
With GDI+, you create a bitmap object of your foreground image (the one with the green background). Then create an ImageAttributes object. Use ImageAttribute's object's SetColorKey() method to specify a color or range of colors to use as the background color. Lastly, draw that bitmap object over the target bitmap, and GDI+ will draw it as if the background color is transparent.
There's more to it in that in code, but concept-wise thats all there is to it.
This is probably an area where it is easier to work in some other space than RGB - such as HSV.
I would also look at the OpenCV library.

Delphi: image with alpha blending capabilities

Is there some simple component that could display PNG 32-bit images and alpha-blend it to another image on mouse enter and on mouse leave? Or even just a simple image that can load 32-bit PNG and additionally would have Alpha parameter...
I suppose I could use some skin library (alphacontrols?) or some graphics library, but for some simple purely visual effects that would be quite an overkill and I can't seem to find a simple one that does it for me and would work on Glass surface as well...
It is not quite a component, but here is a link to a good article on how to do it yourself. Its just a few lines of code:
http://melander.dk/articles/alphasplash/
The basic TImage is capable of displaying a PNG image and alpha-blend-it to whatever is behind it. You just need to add the "pngimage" unit to the uses clause of your form. You didn't mention the version of Delphi you're on: Delphi 2010 has this unit, but I have no idea with what version of Delphi they started shipping it. For Delphi 7 I know for sure you'll need to find the open source "pngimage".
If you need to do this when the user moves in and out of your control, consider caching the state images in bitmaps: it will be faster at runtime and you can use a single TImage that shows the current image, you don't need two overlapping TIMage controls.

Resources