2009年5月24日日曜日

Good morning!


I studied the "YubiFude" application.

I could save the image of PaintingView(UIView class)

and imported image in the photo liblary to the PaintingView(but not complete)

 and changed the value of color and fill color (0.0~1.0→0~255).

I save image of the PaintingView by reffered to this.

 ******code ******

- (void)saveViewToPhotoLibrary:(id)sender {
 
  CGRect screenRect = [[UIScreen mainScreen] bounds];
 //↑↑↑get the size of window:
  UIGraphicsBeginImageContext(screenRect.size);
 //↑↑↑Creates a bitmap-based graphics context and makes it the current context.
 
  CGContextRef ctx = UIGraphicsGetCurrentContext();

  CGContextFillRect(ctx, screenRect);
 //↑↑↑Paints the area contained within the provided rectangle, using the fill color in the current graphics state.
 
  [self.paintingViewController.view.layer renderInContext:ctx];
 //↑↑↑Renders the receiver and its sublayers into the specified context.
 //UIView class has a layer property.It is a CALayer class object  
   
  UIImage *screenImage = UIGraphicsGetImageFromCurrentImageContext();
 //↑↑↑Returns an image based on the contents of the current bitmap-based graphics context.
 
  UIImageWriteToSavedPhotosAlbum(screenImage, nil, nil, nil);
 //↑↑↑Adds the specified image to the user’s Saved Photos album.
 
  UIGraphicsEndImageContext();  
 //↑↑↑Removes the current bitmap-based graphics context from the top of the stack.
}
***************

Therefore, I could do it.

I could import image in the photo liblary to the PaintingView.

But It's not complete yet.

It is difficulty problem here. ,,, layer problem,,,?

I don't know it well.

Therefore, I'll understand it at tomorrow.
 

0 件のコメント:

コメントを投稿