TImageList/TListview: correct design choice? - delphi

This is a question about picking the right Delphi components.
Using Delphi for a new app.
I'm looking to allow my user to have a list of (his own, on harddisk) pictures (just jpg for now, but should support different formats in the future), import them into my app, and then display them to him in a TListView. I was planning to tie that TListView to a TImageList (since this comes out of the box)... but when I tried, I ran into a set of weird problems about importing jpg's into a TImageList, reported here:
TImagelist not adding bitmap
So I'm wondering, am I using components for something they aren't intended for? Specifically, is the TImageList (even with some pre-formatting on import) useful for this kind of freestyle-all-sizes-and-formats-allowed stuff?
Any advice appreciated!

TImageList is designed to contain images of stored with the same format and size. If I am understanding correctly, TImageList doesn't do what you ask for.
TListView is tied to TImageList and therefore has the same limits. In my experience, a component flexible as you ask requires a custom component and manual drawing.
If you could change the requirement and decide a fixed size, you can preprocess the images making a thumbnail of the decided sizes and store them in the image list. This way you avoid building a component specific for your needs.

Related

Is there a graphical tool for Mac to assist in positioning CCNode objects on a Layer?

If my designer gives me a 960x640px image of what the screen should look like, as well as all of the individual elements as images or text, is there a way to lay out the images and text on the iPhone/iPad screen without doing it manually through code? The way I'm doing it now is a series of trial and error, trying to guess the position of each element.
By the way, the types of layouts I'm trying to do are simple static layouts for stuff like Menus and High Scores lists, etc.
You should try one of the editing tools: LevelHelper, CocoShop and CocosBuilder. The problem will be the output format, make sure that not only the editing part works to your specification but that you can actually use just the snippet of code you need to plug it into your code.
Do you have an image-editing software like Photoshop or GIMP? How about opening the 960x640px image with any such software, then hovering your mouse over the center of each element for its coordinates, and then finally pumping these values into your code?
In my opinion, this is at least better and way faster than trial and error:)
If you want to measure position of graphic elements. You can try a commercial called xscope. The trail version can be downloaded form their official website. It is the best tool I ever seen to measure distance, color(like, it can copy color measured directly to [UIColor ...] format), etc. If you want something freeware, I would like to recommend markman, which is a Chinese software, it's built on adobe air. All elements/button are graphic, so you don't need to read chinese to use it..
You can try to use some open source editor and write your exporter. For example I am using blender as a level editor for the game I am working on. It has a nice python API that can be used to export all the information you need.

Ugly "disabled" images of TMainMenu

Delphi 2010, Win32 VCL. I need to create a main menu for my application with the most standard look. TMainMenu looks nice in all Windows versions, the only bad thing is when it displaying images for items with Enabled=False.
Delphi has some strange method for building that disabled images (b/w extrusion with bevels, for me it looks like spew). I want to make a patch for that procedure in VCL sources and let menu to select disabled images from the same TImageList, but I can't find it.
Is it exists at all or it is some standard windows API call? Do you know where is that procedure located?
Sure OwnerDraw style can fix all this but I want a bit faster solution.
There's a great post on Galfar's Lair blog which describes the problem, and has code for a workaround, overriding the TImageList DoDraw method.
Here's the pic (linked) showing the 'before' and 'after'.
I think this relates to pretty much all Delphi versions.
If you can provide your images as PNG you can use TPngImageList from PngComponents. It has different options to make a blended or grayscaled disabled image. The PNG format allows you to make use of alphablending.

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.

Looking for a simple graphical component for Delphi

I am looking for a graphical component in Delphi winch have such features:
allows to paint text in different font types, sizes and colors
allows to select previously drawn text and copy it
paints images on a given coords, gif support would be nice
its very fast in terms of CPU usage
I need this component as a main chat window. I don't want to use it as a text editor.
I've tried two solutions so far:
TVirtualStringTree
THtml
Currently I am using THtml. It performs quite nice but it is a bit to slow due to two facts:
It supports many features which are not necessary in my case
Each time I want to add some content to it, I must reload the whole content
I really don't want to go into its sources and modify them until I have no other choice. So maybe someone of you knows some nice lightweight component which I can use instead?
Take a look at TRichView. It's derived from TCustomControl so no external dependencies. It's third party commercial component, but a very good one. Skype Win client uses it.
What about a TRichEdit? Most of the things you mention should be easiliby possible with this component.
Concering the insertion of a bitmap, see this article on Delphi 3000.
Did you consider using TWebBrowser?
At least it ticks all your boxes...

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