Silverlight Image Positioning/Transformation - silverlight

What I would like to do is the following:
Change the points of the four corners of an image.
What is possible now, is to change the top left corner. But that will only move the image.
I want to transform the image by changing the corner coordinates.
The effect will be a 3d-kind transformation.
A skew transformation will not do, I want to be able to position the corners freely.
Is this possible?

I don't think you can just place corners of an image arbitarily and have it distort accordingly. It might be better if you specified the effect you are trying to acheive.
There are couple of options which may or may not suit.
Would a Matrix3DProjection serve your purpose (as well as do a lot a math for you)?
Would using the image to Fill a path or using a path to clip the image get the effect you want.

Related

how to scale an image with gimp and save the actual scale and all the white space

there are a ton of scaling instructions for GIMP but all of them tell you to scale and save easy peasy. I feel like I'm taking crazy pills.
This is what my save or export generates:
How can I simply export a selection? Shouldn't the GIMP instructions include this detail? Sorry for ranting.
In Gimp (and some other popular image editors) the image you work on is actually made of separate images (a.ka.a layers) held together on a "canvas". The "canvas" gives the size of the final image.
There are three different ways to scale things and you have to use the right one:
The Scale tool : scales the active layer by dragging corners. Doesn't change the size of the canvas. This is probably what you used.
Layer>Scale layer: scales the active layer by providing explicit dimensions. Doesn't change the size of the canvas.
Image>Scale image: scales the whole image contents and the canvas. This is probably what you should have used.
What happened to give you the image above is that you resized the layer using the Scale tool, so you got a tiny image in the corner of the canvas, which didn't change size. The uncovered part of the canvas was displayed as a checkerboard pattern. If you exported to a format that supports transparency such as PNG or GIF the image would have been transparent, but since you exported to JPG which doesn't support transparent images Gimp replaced the transparent part by the default background color.
Everything is well explained on their website. https://www.gimp.org/tutorials/GIMP_Quickies/

iOS 6 AutoLayout Scale and Translate Animation

My aim is to have 3 images shrink, grow, and move along a horizontal axis depending on selection. Using Auto Layout seems to make the images jump about as they try to fulfil the Top space to superview / Bottom space to superview constraints.
So to combat this I have put all the images inside their own UIView. The UIView is set to the maximum size the images can grow to, it is centred on the horizontal axis. So now all the images must do is stay centred inside their corresponding UIView. This has fixed my problem as the UIViews perform the horizontal translation, while the images shrink/grow inside while remaining centred. My question is - is this the correct way to do this? It seems very long and like I am perhaps misusing the ability of Auto Layout. I have to perform similar tasks with more images and so any advice is welcome! Thanks.
I've just written a little essay on this topic here:
How do I adjust the anchor point of a CALayer, when Auto Layout is being used?
Basically autolayout does not play at all well with any kind of view transform. The easiest solution is to take your view out of autolayout's control altogether, but alternatively you can give it only constraints that won't fight back against the particular kind of transform you intend to apply. That second solution sounds like just the sort of thing you're doing.

Rectangular shaped Gradient Fill

I'm currently looking to achieve a gradient effect a bit like the rectangle in http://pjnicholson.com/Fireworks/fillgradients.htm
If I compromise a little I can get close to this using RadialGradientBrush... but is there any (not too painful) way to achieve the rectangular effect?
Use an ImageBrush instead and use this image (or a similar image generated using some image editor) for the background of your rectangle.
One solution a colleague and I came with was to derive a new Panel that used a WriteableBitmap as the source for its background.
The panel will give you the dimensions you need to make your WriteableBitmap. Using whatever algorithm you want you can fill it appropriately. In our case, we needed a radial or cone gradient, but the same concept applies.
Additionally, you can create several properties on your new control to specify the colors for the gradient. We adapted a LinearGradientBrush for our needs, but if you're working on just two colors, simple properties may suffice.
I don't have the code handy but will try to find it and post an update later. But the above should get you going.

Clipping Paths in Silverlight Mobile (WP7) - I can't create anything but a simple rectangle?

I'm trying to create clipping paths for shapes, such as circles, polygons, etc. I'm actually trying to make the clipping path follow the line of the shape. I've tried the below in Expression Blend, what am I missing? What I'm really trying to do here is have the user trace shapes with an InkPresenter, and have it error if they've drawn outside the lines X times... if Clipping Paths is the wrong way to go here, by all means please let me know what the correct direction is :)
I created a rectangle, rounded the edges until it was a circle and then Make Clipping Path was enabled. I select it and I get the error: "Rounded corners are not supported for clipping paths in Silverlight 4 Mobile and have been removed."
Then I created about 50 rectangles over the circle, then Make Compound Path... and now Make Clipping Path is disabled again
Then I left the 50 rectangles as just Rectangles and thought I'll just create each of them as a Clipping path... I do the first one, so far so good... I select the second and make it a Clipping Path for my InkPresenter, and it deletes my first Clipping Path and uses the second. Dead in the water, it looks like each object can only have one clipping path.
How do I get around this?
Tim
You can use a PathGeometry to create an arbitrary shape geometry that you can assign as Clip to your InkPresenter.
You can build up the points for the PathGeometry from input events as the user traces the shape.

KML + Google Earth: Fill a quadrilateral with a bitmap?

I'm building a KML file to use as a map layer in Google Earth and whatever else handles KML/KMZ files.
What I want to do is this: Display a number of bitmap images such that each is stretched to fit into a specified quadrilateral, where the first vertex of the quadrilateral specified would, for example, be the top-left corner of the bitmap, the next vertex would be where the top-right corner fits, and so on. Is there a (relatively) simple way to do this? If distorting/stretching the image isn't possible in any simple way, just displaying it at a specified location, scaling and rotation would be acceptable.
Update: To clarify: Given a set of four geospatial coordinates that form a quadrilateral, I'd like to take a rectangular bitmap (either via a specified URL or included in a KMZ file) and lay it onto the map such that its four corners line up with the four corners of the aforementioned quadrilateral. If it's not possible to distort an image to fit any quadrilateral, it would be sufficient to just specify position, rotation and size. Hopefully that's a little clearer.
Any help would be much appreciated.
Thanks!
Figured it out; you use a LatLonQuad:
<GroundOverlay>
<name>Example Image Overlay</name>
<color>87ffffff</color>
<Icon>
<href>mypicture.jpg</href>
<viewBoundScale>0.75</viewBoundScale>
</Icon>
<gx:LatLonQuad>
<coordinates>
-115.8993079806076,36.72147153334678,0
-115.8990441694222,36.72500067085463,0
-115.9002128356738,36.72511090523616,0
-115.9005214644026,36.72164386079184,0
</coordinates>
</gx:LatLonQuad>
</GroundOverlay>

Resources