This article is part of the 50 Apps by Christmas series
Color Eye is a Windows Phone 8 app that creates colour schemes by sampling live data from the camera.
Working with Live Camera Data
As I’d not worked with the camera in a Windows Phone app before I needed to learn the basics. One of the best sources to get up to speed on a particular specific topic are the samples. I started with the Camera Grayscale Sample to learn how to “pump” the values from the camera and how to get an array of colour values.
More...
SHARE:
[Writing this on the train home so may be a bit rushed – sorry :) ]
Install the Bits
- In Visual Studio 2012, go to Tools menu, Extensions and updates.
- Search for “SQLite for Windows Runtime” – install it.
- In your Windows Store app, install the NuGet package called “sqlite-net” – these are the LINQy wrappers over SQLite.
Use SQLite
Create an “entity” that you want to store in a table, e.g. Customer.
Create some plain properties, choose one to be your primary key, e.g.
[SQLite.PrimaryKey, SQLite.AutoIncrement]
public int Id { get; set; }
public string Name { get; set; }
Create a constant to be the filename of the SQLite db on disk:
private const string dbFileName = "data.dat";
More...
SHARE:
If you are storing images in a SQL Server database you can use the following statement to insert data into a BLOB field (e.g. varbinary(max) ) of a table (Sql Server 2005+):
Assuming a table called AdvertImage with an identity col ("ID") a foreign key column ("FK_Advert") and a varbinary(max) col "JPEGImageData"; you could use the following SQL to insert a new row with the image "C:\motoimage\1.1.JPG" being loaded into the JPEGImageData and setting FK_Advert to 12345:
INSERT AdvertImage
(
FK_Advert,
JPEGImageData
)
SELECT 12345, JPEGImageData.*
FROM OPENROWSET
(BULK 'C:\motoimage\1.1.JPG', SINGLE_BLOB) JPEGImageData
MSDN Link
Sidenote: everyone seems to have a different opinion on storing images (BLOBs) in a database, unfortunately a lot of the time the opinions are written in stone "never store images in the database, always just store the filename to the image on disk", etc. Like any problem you should weight up all the factors such as image size, read vs write volume, will be using a web farm (if so will the images stored on web server need replicating every time one is inserted or changed), how many users, criticality of db image references (e.g. medical images, etc)
There is a good MSDN article covering choice of BLOB types and considerations.
SHARE: