Not sure scrolling around would be the best solution. I would use a writable bitmap and copy the sections of the picture you wanted.
A quick example, been awhile since I have use a writable bitmap. Tested the code, seems to work ok. Code is written to load an image from iso storage, display the picture in image1, copy 100x100 pixels and display in image2.
Change the offsets and width/height to copy whatever you want, something to experiment with.
public partial class MainPage : PhoneApplicationPage |
{ |
// Constructor |
public MainPage() |
{ |
InitializeComponent(); |
GetImageFromIso(); |
} |
|
|
BitmapImage bMap; |
void GetImageFromIso() |
{ |
bMap = new BitmapImage(new Uri("testPic.jpg", UriKind.RelativeOrAbsolute)); |
bMap.ImageOpened += new EventHandler<RoutedEventArgs>(BMapImageOpened); // make sure it is fully loaded |
image1.Source = bMap; // display full image |
} |
|
void BMapImageOpened(object sender, RoutedEventArgs e) |
{ |
WriteableBitmap sourcePicture = new WriteableBitmap(bMap); // make a writable bitmap |
image2.Source = CopyArea(sourcePicture, 0, 0, 100, 100); // copy 100x100 pixels from the upper left corner and display |
} |
|
WriteableBitmap CopyArea(WriteableBitmap inputWB, int xOffset, int yOffset, int width, int height) |
{ |
int SourceWidth = inputWB.PixelWidth; |
WriteableBitmap outputWB = new WriteableBitmap(width, height); |
for (int y = 0; y <= height - 1; y++) |
{ |
int SourceIndex = xOffset + (yOffset + y) * SourceWidth; |
int DestIndex = y * width; |
Array.Copy(inputWB.Pixels, SourceIndex, outputWB.Pixels, DestIndex, width); |
} |
return outputWB; |
} |
} |
|