title: Swift - Saving images as bitmap
body: <p>I am trying to save an image as a bitmap using AVFoundation. Right now I am using jpeg, and was wondering what I would need to change in order to save the image as a bitmap. Side note - we plan on storing the byte[] onto our google app engine and then any device (Android or IOS) that would need the image, would be able to pull the byte[] from the database and convert it into an image on the device. Is this a valid way of going about storing images? If not what would you suggest?</p>
  
  <p>Here is my code saving the image as a jpeg </p>
  
  <pre><code>@IBAction func didPressTakePhoto(sender: AnyObject) {
  
      if let videoConnection = stillImageOutput!.connectionWithMediaType(AVMediaTypeVideo) {
          videoConnection.videoOrientation = AVCaptureVideoOrientation.Portrait
          stillImageOutput?.captureStillImageAsynchronouslyFromConnection(videoConnection, completionHandler: {(sampleBuffer, error) in
              if (sampleBuffer != nil) {
                  var imageData = AVCaptureStillImageOutput.jpegStillImageNSDataRepresentation(sampleBuffer)
                  var dataProvider = CGDataProviderCreateWithCFData(imageData)
                  var cgImageRef = CGImageCreateWithJPEGDataProvider(dataProvider, nil, true, kCGRenderingIntentDefault)
  
                  //change orientation based on if the camera is front or back
  
                  if self.selectedCamera == 1 {
                      var image = UIImage(CGImage: cgImageRef, scale: 1.0, orientation: UIImageOrientation.LeftMirrored)
                      self.capturedImage.image = image
                  } else {
                      var image = UIImage(CGImage: cgImageRef, scale: 1.0, orientation:UIImageOrientation.Right)
                      self.capturedImage.image = image
                  }
  </code></pre>