Image/photo frames - delphi

Is there any good component for Delphi to create a frame like the messenger frame around a photo?

This frame is basically just a bitmap. There seems not to be any function in the Windows API to draw this. Instead, a previous questioner here at SO found that this (or at least a very similar) bitmap is stored as a resource bitmap in explorer.exe, if I recall correctly.
Hence, to write a Delphi component displaying a bitmap inside such a frame would be trivial -- one just have to copy this bitmap. However, I feel this would be wrong (copyvio or at least bad manners). But of course you can draw your own version of a frame /using The GIMP or Photoshop/, and include it as a bitmap.
Also notice that it is very easy to apply bitmap effects, such as hue shifts, to a bitmap during run-time.

Take a look at our MicroPic very small tool.
http://bouchez.info/micropic.html
You've got the source code on the page.
It could be interesting for you, as start for drawing a custom frame to any picture.
I wrote this years ago, just to help my girl friend with her web site, without using photoshop before inserting pictures...

Related

GIF to AVI with windows Animate Control

I was trying to convert a GIF image (Ajax waiting like):
to AVI that will be used with TAnimate control (win32 animation control).
I have tried a few tools, but the problem is that the output AVI is either not suitable for the Animation control or not transparent.
Notes:
I don't use windows XP Themes manifest (D5).
the Common Avi's are transparent even if my program is not themed.
Using the GIF itself to show animation is not an option.
Do you know any tool that can help me with this conversion?
EDIT:
I have tried using ImageMagic with ffmpeg as described here. but I can't seem to set ffmpeg to encode to msrle.
Jasc Animation Shop is able to directly read an animated GIF and write out a compressed AVI. This is an old program that appears to be no longer offered by Corel (who acquired Jasc), but you may still be able to find the free trial version for example.
You could try the TGIFImage component (written for Delphi 5), which claims not only to support Animated GIFs, but also Transparency, as well as a means of converting a GIF to an AVI (and vice-versa).
Whether it does all that or not I cannot say as I haven't personally tested it. Like TLama mentioned in the OP comments above, I use my own means of playing each frame in an animated fashion (only mine uses a RES file and a TImage, where each frame is stored as a PNG for full semi-transparency support).
Many commercial tools do this conversion, including Corel Photo Paint, and others. A free trial is available for Corel Photo Paint, which comes included in the Corel Draw package. (Warning: It's huge, and expensive.) I don't think the transparency will be solved any more by corel photo paint's conversion than by anybody else.
Typing some words into Google, also reveals that DSPack from ProgDigy might help you.
The last time I did this, I abandoned the attempt to convert GIF transparency into AVI-with-transparency, because no AVI-encoding tool that I could find would preserve transparency. Thus the solution of leaving it as a gif, and putting a new control into your app (as LaKraven suggests) may be superior in the end, to fighting it.
I would suggest using GDIPlus native image renderer which can easily handle animated GIFs as well as many other image types, including multi-frame TIFFs (no MNG so far). I was able to find an example component which animates TImage instance:
http://www.progdigy.com/forums/viewtopic.php?p=13156
Please note I am aware that you are looking for a solution to AVI transparency, this is just an alternative way of presenting user with a "progress", which seems to be more lightweight (no dependency on windows media playback facilities) and flexible (such animation controller can be used on any image).

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 do I print a partially transparent image to a PDF Canvas using Delphi?

My program needs to output a (fairly complex) form to the printer, including several images. I’m currently doing this using Delphi (2006)’s Printer.Canvas, after selecting a PDF printer (PDF995). This works like a treat.
However, I’m now running into a problem: there’s one partially transparent image that needs to be placed on top of other elements (borders, background and such), with portions of that text still visible through parts of the image.
Doing this on a regular screen Canvas works fine with regular TBitmaps, by using the TransparentColor property. However, when I try to do this on a printer, it doesn’t always work; and when I try this on a PDF printer, it never works: the background turns black, or (the best result so far), turns white, but still overwrites anything underneath it.
I’ve tried achieving the same result by inserting a PNG image with alpha transparency (a.k.a. translucency) in a Word document, and then sending that to said PDF printer. The translucency disappears, but pixel transparency is maintained. So that, at least, should somehow be possible.
Anybody know how?
You mention you are using the TransparentColor property, so is it correct to say you don't really need alpha transparency and can get away with using binary transparency (transparency for each pixel is either off or on)?
If so, it might be possible to generate a Region from your bitmap.
You then use this region as a clipping region and draw the bitmap.
The PDF printer might be able to handle a clipping region correctly.
Here's an example of generating a region from a bitmap, it's used to make non-rectangular forms but the idea is the same:
http://www.delphi-central.com/BitmapShapedForm.aspx
Here is another example of setting a clipping region for your TCanvas:
http://www.efg2.com/Lab/OtherProjects/PrinterDemo2.htm
I don't think you can achieve partial transparency using a pdf printer. What you can do is get the VisPDF package. With it you can add a mask to the images contained in the pdf that you actually produce right in you're application. If this is not an option, you could combine all your background stuff in to one image. Drawing the alphachanneled thing on this image.
I also had this problem before, If I recall correctly, what I ended up doing was to create an off screen bitmap that I manipulated, then after I was done copied again and used the new bitmap copy on the canvas I was sending to the printer.
You may want to consider using a third-party PDF component in your application to render the canvas directly to PDF. I use this technique for specialized reporting (RTF, Radioemtric JPEGs, Tables, Text etc) in a commercial product I developed for Infrared Thermography. I am very happy with the performance and quality. The component I am using llPDFLib was just updated and I believe now supports full image transparency.
Best of luck. Printing images with an Alpha channel can be challenging at times in my experience.

Where can I find an image watermark control for 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.

Resources