What is the appropriate way to dynamically load a png image from file into a Timage on a Tpanel, thereafter resizing/ zooming/ panning it? - image

I do a LoadFromFile() for a PNG image into a Timage that is on a TPanel on a Form. The Form's OnCreate event maximizes the Form, and the Panel is set to alClient so it resizes nicely. But the PNG image does not, it only fills to the TPanel's design-time dimensions. And it looks horribly low resolution, no matter how hi-res the source image is.
I get it to resize in an OnClick event by using Image.SetBound(), but it does not look good.
I have also tried with a BMP and JPG, but without success.
I am guessing there is something fundamental I do not understand, but I cannot find the 'recipe' for this anywhere.

Related

nothing happens when I attempt to textout to a transparent image

I am using Lazarus.
I have put 2 images on a form and synchronized their positions and sizes.
I can textout to both images, and after I made the ontop image transparent I can see the combined content of both images.
I can add further text to the bottom image and see it, but I can't see text I try to add to the transparent image.
I used the following code to make the top image transparent
image2.picture.Bitmap.TransparentColor:=clWhite;
image2.transparent:=true;
I guess I need to play with the image bitmap, but I can't find a solution that is not using other software.
Can someone help me with this please?

Delphi PNGImage - Image transparency is not pure

I am using PNG images as main image resource in my application. Since im using Delphi 7, i downloaded PNGImage lib and included it in project. I load images like this:
Form.image.Picture.LoadFromFile(PAnsiChar('\background.png'));
Image has transparent and semi transparent pixels on its border. The problem i get is that transparent pixels are filled with random zoomed part of my desktop with currently opened windows, while i expected to see what is actually located beneath form.
Additionally, form has this properties:
BorderStyle: bsNone;
TransparentColor: true;
Visible: false;
Here is a picture of current state (above black line) and desired:
Can this be fixed somehow or it is how delphi deals with transparency?
To have the form "shade" what's beneath it, use the forms AlphaBlend and AlphaBlendValue properties. The .png image doesn't have to be partially (alpha blended) transparent, but it can be.
If you want the form to be semi-transparent you use Alphablending, that's a limitation of Windows. In addition you can have a certain color fully transparent. In the following sample the forms color is clGray, which is also defined as the Transparent color property in addition to the Transparent property set to True. The image, aligned alClient, is 50% transparent, placed on a TImage which is set as transparent, but even so, it doesn't show up as semi-transparent unless you have AlphaBlending on. Again, this is a limitation of Windows. The best you can do is try with a fairly high value for AlphaBlendingValue (240..250) and a rather light image to find the right compromise.

Cross browser image hover effect that works with Masonry jquery plug-in?

Wondering if anybody could help me out. I have the Masonry jquery plug-in which is laying out a set of images and when you zoom in or out in the browser, they change place to fit more/less of the images on the screen. Is there a way to, when i hover over these images, they would fade to black and a description of the image would appear in it's place.
A bit like http://www.flickr.com/ but rather than the small box at the bottom when you hover on an image, a box that covers the whole image and each seperate image can have a seperate description.
some possible hover effects is like Image effects, like grayscale, blur, sepia, etc. I still haven't figure out the best hover effect that have fix height/width.

Convert StdPicture Transparency Colour to White

I am using a CodeJock ImageManager component to hold a variety of images. I want to put one of these images into a FlexGrid Cell.
The Images I have are Png format and have transparent backgrounds so when I load the image into the grid like so:
Grid.Cell(flexcpPicture, 123, 4) = _
ImageManagerControl.Icons.GetImage(ImageNum, 16).CreatePicture(xtpImageNormal)
the background which in the original image was transparent is now black:
(the same happens if I load the image into a PictureBox using the above method)
According to the documentation CreatePicture returns an StdPicture object, is there some way I can convert this image (using BitBlt perhaps) so that the black is white? I'm not sure if this even possible?
I only need to do this with about three images so if I have to load them into an ImageList or something else first that would be ok.
I'm not sure if this helps at all, but I've been playing around with the PictureBox. I put two picture boxes on a form, put a bmp file (this only works with bmp files, so it might not be helpful to you), and did this:
Picture2.PaintPicture Picture1.Picture, 0, 0, opcode:=vbNotSrcCopy
Which successfully inverted the bitmap. Here are the RasterOp constants: http://msdn.microsoft.com/en-us/library/aa243035(v=vs.60).aspx

masking with an image in iOS

I'd like to take an image and use it as a mask for a view on which I add numerous image views. I know of the quartz CGContextClipToMask() call but what would be the best way to approach this? Can I override the drawRect method of a container view, call CGContextClipToMask() within it, and then expect its subviews to adhere to that clipping region? It doesn't seem to work.
Do I need to instead add some blocking mask image over top?
Instead of subclassing or overriding drawing functions, I chose to overlay the images with an image that had transparency in the viewable portion. i.e., if my 'surface' was an image of a parchment, and I aimed to draw a bunch of images on it. I would have the parchment image, then a container UIView for any images to be put on that parchment, then a masking image over top of that which was the original parchment image but with the parchment itself converted instead to full transparency, while the surrounding area is left exactly as the background the parchment is on (then all other UI widgets over top of that).
This seems a viable solution in all cases except if one were to need some image to visually animate around and behind the parchment (not my case).

Resources