Draw on an image in iPhone app - iphone

I'm fairly new to iPhone app development. I'm trying to make a scrapbook app (for fun sakes) but I can't figure out how to draw on and add pictures to my template which is also an image file (and a UIView). Should I save my template as a pdf? Essentially I don't know how to add stuff to my template - for example draw shapes on it, add a text box, add a picture, etc
Please help!!!!!

No PDF needed. Check out Quartz 2D:
https://developer.apple.com/library/ios/#documentation/graphicsimaging/conceptual/drawingwithquartz2d/Introduction/Introduction.html
You create a context (e.g., via CGBitmapContextCreate), add you bitmap (e.g., via CGContextDrawImage), draw text (e.g., via CGContextShowTextAtPoint), etc.
Review the Quartz 2D introduction above, and then review some the Quartz 2D code samples. It's not hard, but it's not obvious, either. Just takes a few times to get the hang of it.

Related

Delphi - How to make a PNG image the main form?

I have an application which the main form of it its called Fmain. How can i make the Fmain to be the PNG image which i have as Image1 assigned in my source?
FMain.brush.bitmap:=Image1.picture.bitmap;
that's for if the Image1 is a *.bmp one, but i need the transperancy of my PNG file.
I don't think you will be able to make a custom shaped TForm with a transparent png.
Have a a look at this answer Irregularly shaped forms and more specifically to this http://docwiki.embarcadero.com/Libraries/XE2/en/Vcl.Forms.TCustomForm.TransparentColorValue .
Are you wanting to make a form that has an odd shape? As in, you want to have the transparent parts of the PNG not be clickable as a form? If so then you are going about it the wrong way. If you were to put an image on the form and set the transparent properties on the image, then all you will do is see the form behind the image.
If you want to have a form that is the shape of the visible area of the PNG then you need to create an oddly shaped form. This is done by using regions and SetWindowRgn.
Luckily there is a handy tool out there for this: Gabes OddForm Assistant. I have used this to great effect a number of times.
In order to use it you will need to save your PNG as a bitmap and then load it into the utility. Once it is done it will give you the code required to make the form. You can just have a look in the pas file it creates and see how it is done, tinkering if you feel the need. You can either use the form directly or graft the code to where you need it.
Hope this helps.

How to draw a Pixmap with partial transparency in GTK application

I'm just getting started with Mono programming using GTK, and have been pleasantly surprised. However, I have come across a hurdle I haven't been able to get over yet.
In the app I'm working on, I am able to load a JPEG image into a Pixmap and draw it to my GUI's Drawing Area. That works fine. However, I want to be able to take a second JPEG image, make it partially transparent, and draw it over the first. So far, I haven't been able to figure out a decent way to do this.
Is it somehow possible to change the alpha value of an entire Pixmap before I draw it? I'm not sure where to go from here.
If you're using GtkDrawingArea you should be using Cairo to do the drawing itself. As an alternative to using cairo_paint() there is a cairo_paint_with_alpha() which lets you specify the opacity you wish to paint with.

Coding a photoshoped GUI for iOS devices

well... I have searched for a while on topics of coding given GUI elements by designer in photoshop format. But I have a really hard time getting it together. Just for an example. When I would like to make an app with only a simple LCD-Display with a timer, counting down, how would I start there..... Don't get me wrong, I am aware of doing the code behind the scenes to make the timer count etc.
But what about setting up a nice looking gui with glossy display effect? What is a "correct way" to implement such a gui? Taking a Photoshop file showing a glossy display and setting a UILabel on that? or coding the gloss effect programmatically?
This is just one example... hm... I do not find good ressources for getting a start on such a topic. I would be really gladful if you could give me a helping hand for a start.
In the typical app development cycle, you would have the graphics people delivering graphics to the programming people, in the form of PNG files.
However, it is very well possible to render all kinds of things on the fly on the device. The blue shade on the tab bar icons in any app using UITabBarController is a clear example: the programmer puts in a PNG with just the alpha channel, and the system renders the blue shading.
Using Quartz Core (look for CGContext in the documentation) you can draw lines and text, and apply all kinds of transformations, gradients, clipping paths, etc. Using this you can create your own styled subclasses of UIView and such.
The PNG approach is generally the easier way.

How to draw over text, or highlight/underline something in a UIWebView?

I need to develop an application like an eBook reader, that loads PDF or HTML files. This part is easy. The part where I'd like some reference or example is the feature that allows the user to highlight/underline text with the finger, or draw circles or ellipses around the text. So you activate the "pencil" or another drawing tool, and "draw" over the text, to highlight some parts.
Is there any example around?
The best option here is to create a transparent context in a CGLayer in Quartz and do your drawings, then copy the result back as an image and put it over the text view. See this for references about Quartz.

Is it possible to restore a previous GL framebuffer?

I'm working on an iPhone app that lets the user draw using GL. I used the GLPaint sample code project as a firm foundation, but now I want to add the ability for the user to load one of their previous drawings and continue working on it.
I know how to get the framebuffer contents and save it as a UIImage. Is there a way for me to take the UIImage and tell GL to draw that?
Any help is much appreciated.
Typically you would either:
1) Use glDrawPixels()
2) Load the image into a texture and then render a quad.