Yes You Cam
A Ridiculously Simple BluePotion Camera Library to help you achieve your dreams...
Usage ("Nothing is impossible")
Take a Photo
YesYouCam.capture_photo
On Take a Photo Completion - Get Photo
def activity_result(request_code, result_code, data)
if (request_code == YesYouCam::CAPTURE_IMAGE_RC)
if (result_code == YesYouCam::OK)
mp "Full sized photo located at #{YesYouCam.photo_path}"
else
app.toast "No Photo"
end
end
end
Want a PNG?
YesYouCam.photo_path
YesYouCam.pic_to_png
YesYouCam.photo_path
Need the photo discoverable by Photo Libraries and other Apps?
YesYouCam.add_to_gallery
Let the user select a photo from their library?
YesYouCam.choose_photo
Kitchen Sink Example
app.alert(title: "Update Photo", message: "How would you like to update your photo?", positive_button: "Take Photo", negative_button: "Choose from Library") do |choice|
case choice
when "Take Photo"
YesYouCam.capture_photo
when "Choose from Library"
YesYouCam.choose_photo
end
end
def activity_result(request_code, result_code, data)
if request_code == YesYouCam::CAPTURE_IMAGE_RC
if result_code == YesYouCam::OK
mp "Full sized photo located at #{YesYouCam.photo_path}"
find!(:some_image_view).imageBitmap = YesYouCam.bmp_data
else
app.toast "No Photo"
end
elsif request_code == YesYouCam::CHOOSE_IMAGE_RC
selected_uri = data.getData
photo_path = YesYouCam.pic_path_from_uri(selected_uri)
bmp_data = YesYouCam.bmp_data(photo_path)
find!(:some_image_view).imageURI = selected_uri
end
end
Installation
Add this line to your application's Gemfile:
gem 'yesyoucam'
And then execute:
$ bundle
Now make sure your Rakefile
has camera permissions and features needed:
# This gem will try to add permissions, but it's best that you assure they are set!
app.permissions += [:write_external_storage]
# This gem will add this feature, but it's safest for you to also set it!
app.features = ["android.hardware.camera"]
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Order some mexican food and beat a piñata
- Create new Pull Request