WP7 equivalent of Android 9-patch or iOS UIImage rightCapWidth? - image

I'm working on a WP7 app and can't find any way to stretch an image only at a specific point (repeating that row of pixels). For example, if I have a box with rounded corners I want to stretch it to fill a specific area only I want to stretch just a few pixels in the center (horizontally and vertically) so that the corners are unmodified.
In Android you can do this with a 9 Patch image and in iOS UIImage provides methods such as rightCapWidth.
What's the equivalent for WP7?
Thanks.

There is, currently, no direct equivalent for WP7.
You'll have to adjust the image as you need to for your requirements.
As applying rounded corners to everything doesn't match the Metro design principals for the phone, I expect there is little reason for, or likelihood of, such functionlaity becoming part of the core APIs.

Related

LÖVE viewport like Libgdx

I wonder if LÖVE framework has the same feature like Libgdx's viewport, because this feature were really great when I used Libgdx and I wonder if there's anything similar to do in LÖVE.
About viewports: https://github.com/libgdx/libgdx/wiki/Viewports
If, by viewport, you mean using normalised coordinates (resolution-independant), then yes, LÖVE can do that.
Although it's not available by default in the framework itself, there's always a possibility to add your own features.
You could make a Viewport system using LÖVE's canvases.
Start by creating a canvas with fixed dimensions,
then make your game using percentages of these dimensions instead of regular pixel positioning.
For example, player.x = 80 (left side of the screen) becomes player.x = canvas:getWidth()*.1
Once you've drawn everything into your virtual window -that is- the canvas, you can scale it and render your game to fit any window resolution.
I suggest that you take a look at this library that handles all the scaling stuff for you, once you provide your game's virtual dimensions.

How to make an app for the 4inch screen in xcode and not stretch it out

When I make my app for the 4inch screen i just stretch it out! I dont want to do that i want it to look the same when running on the iphone 4 and the 5.
You need to have a portion of your image stretchable, for example, if you have a rounded corner background, you could stretch the centre of it without deforming the corners. Same goes for any other type of background (I assume you have a background that needs to be stretched). Once you decide what portion of it you want to deform, you can use UIImage's stretchableImageWithLeftCapWidth:topCapHeight: to avoid stretching the rest.
If you're not ready to compromise and stretch a portion of your image, I'm afraid you'll have to use 2 different images, one for 4 inches (iPhone 5) and one for 3.5 inches (iPhone <5).

Optimal WP7 bitmap drawing with XNA

I want to display a bitmap on a WP7 in vertical position, but it rotates it 90 degrees and coordinates are in landscape position. Is it possible to make WP7 display everything in vertical mode and make coordinates starting from top left corner in vertical mode? If not, whats the best way to display my bitmaps in vertical mode? Should I rotate my bitmaps when I design them, or should i use rotation in my drawing functions? I use XNA spriteBatch.Draw to draw my bitmaps, but it has some advanced rotation techniques that I don't understand.
XNA apps are based on the assumption that the game will be displayed in landscape mode. Whether it's easier/better for you to rotate things at design time or when displayign them in the app will depend on various factors, including: what the game does; your preferences; the number of items; the impact on movement calculations; etc...

Cocoa / CoreGraphics / Quartz - borderless Quicktime X like window with rounded edges

I am developing a document based application for Mac OS X. It's a kind of media player, but instead of playing audio or video files it is supposed to open text-files containing meta-data specifying OpenGL animations. I would like to mimic Apples QuickTime X window style. This means, i have to do all the window drawings myself, because Cocoa has no appropriate window style.
There is one thing which gives me headaches: The rounded corners usually to be found on Mac OS X windows. I tried using the borderless window mask and working some CGS magic - there are some private Apple headers which allow window shaping, but they are of course undocumented. I was able to cut rectangular holes in my windows edges, but i couldn't figure out how Apple achieves rounded corners.
Creating a transparent window and drawing the frame myself does not work, because an OpenGL viewport is always rectangular, and the only way to change it is to turn on NSOpenGLCPSurfaceOpacity for alpha transparency and using the stencil buffer or shaders to cut out the edges, which seems like a hell of a lot of overhead.
If i put an OpenGLView into a standard Cocoa window with titlebar, the bottom edges are rounded. It seems this is happening at the NSThemeFrame stage of the view hierarchy. Any ideas how this is done?
Use a layer-backed view, and do your drawing in the CALayer on an invisible window. Layers include automatic handling of rounded corners and borders.
Background for CALayer is in the Core Animation Programming Guide. To create a layer for NSView, you need to call [view setWantsLayer:YES]. You would create a CAOpenGLLayer and assign it to the view using setLayer:.
See CALayerEssentials for sample code demonstrating how to use CAOpenGLLayer among other layer types.
Since Robs suggestion didn't work and no one else contributed to the discussion i settled on using the stencil buffer to crop the windows corners. I did this by creating a texture from the windows background and rendering it into the stencil buffer, discarding all transparent pixels. Looks fine, but is slow when resizing the window :/

NSImage Overlay/Mask Gradient like iOS

I'm looking to replicate with Cocoa/Core Graphics the process which seems to occur on iOS when setting an image for a UITabBarItem. When the tab bar item is selected, the image is overlayed with a gradient.
For example,
becomes...
I'm unsure exactly what I should be doing to achieve this effect. It seems like the image is masking the gradient. Any pointers in the right direction (or code!) would be much appreciated.
You can use a monochrome CGImage with alpha channel (like most iPhone tool-/tabbar icons) as a mask. Basically, you'd use CGContextClipToMask with your monochrome image. Then you'd draw the gradient which is then clipped to the mask image. You might also want to have a look at the code of UMEKit, which implements this effect on Mac OS X (haven't looked at how exactly they do it, there are probably several ways).

Resources