Make a BitmapField go full screen when clicked - blackberry

I am writing an app that does live streaming. Can I make a bitmap field go full screen when clicked?

The easiest way to do it (that I could think of in 2 minutes):
Make your bitmap clickable (described here)
When the bitmap field is clicked, scale it into a new bitmap the size of the whole screen:
Bitmap scaled = new Bitmap(Display.getWidth(), Display.getHeight());
originalBitmap.scaleInto(scaled);
Create a new Screen, containing only a BitmapField (with your scaled bitmap)
Push the new Screen.

Related

Constrain image Movement in Specific Area in Window RT App

Ok.
To describe what I want to do, have you ever used Telerik Crop function Image Editor control?
I want exactly same functionality.
I want to use that control but, I am working on Universal app that has no control like Image Editor from telerik.
That control does are
1. There is a fixed rect or canvas for cropping image.
2. If the original image is in the area of canvas(or Rect) image's opacity = 1(i guess) and if the original image is out of canvas area, image looks dim(maybe opacity 0.5 or some)
3. Constrain original image movement in the canvas.
I will implement this function in Image.ManipulationDelta event.
Do I have to get each point value of canvas? or can I do it by using Width or Height of Canvas?
How Do I do that?
Can anyone help me?
any hint?
I'm not familiar with that particular control, but I think I understand what you want.
To constrain the movement of an Image within a Canvas you can check where the Image will end up in your ManipulationDelta and limit any translation, scaling, and rotation appropriately. If the bounding box of the Image after the transform applies is within the Canvas then apply the transform. Otherwise roll it back and do nothing. I have sample code for this in my blog entry: Constraining manipulations
To dim the area outside of the crop I'd create a shape and fill it with a partially transparent brush. The all-in-one code framework sample How to crop bitmap in a Windows Store app demonstrates this technique. I believe the sample targets Windows Store 8.0 apps, but essentially the same code should work on Windows Store 8.1 or Windows Phone Store 8.1 apps.

Canvas element, image resizing and saving

I'm working on a toy JS project to apply filters to an image.
If I do the following:
add an image to a page via FileReader and Drag and Drop
apply said image to a maximum height/width of 500px canvas element via drawImage
apply changes to said canvas via putImageData
save the canvas via Canvas2Image
will the saved image be the size of the canvas element or the original image dimensions?
The mage you create from canvas will always be at the size of the canvas. The canvas does not know what you draw into it so the original size of the image does not matter.
I don't know what Canvas2Image will do to the resulting image, but you can simply extract the canvas as an image using:
var dataUri = canvas.toDataURL('image/jpeg');
This will save the image at the size the canvas is at (I assume Canvas2Image will do the same where it can or simulate this approach for bmp formats etc.).
To prompt the user to save the dataUri as an image please see my earlier answer here.

Blackberry Bitmapfield taking space on screen but not showing in horizontalfieldmanager

I am using this code -
HorizontalFieldManager hfm = new HorizontalFieldManager();
this.add(hfm);
Bitmap HELLO_LOGO = Bitmap.getBitmapResource("test.jpg");
BitmapField helloBmpField = new BitmapField(HELLO_LOGO);
hfm.add(helloBmpField);
I have 3 files in the img folder under res - test.jpg,icon.png,tester.gif
I also have a labelfield in the horizontal manager.
Either of them show now but not both. I have checked the size of the image that is fine too.
I have tried all 3 files one by one - it takes up some space on the screen but the image doesn't show up with any of the 3 files
Can someone please tell me what am I doing wrong
Thanks
You could add some debug output statements to this code, and check if the image is loaded.
Missing some context, I assume this code is taken from the constructor of a Screen class. If not, this could be a problem with the event-handling thread.
First check: is the filename comlete? should it be "img/test.jpg" instead of "test.jpg"?
Check the extension of the name of the image you have put in your res folder. May be the image is named as test.JPG (capital letter for extension) in the res folder but in your code you've written test.jpg (small letter for extension) or any other naming mistake like this...

Blackberry: Text too small when put on actual device

I used the 9330 simulator for developing my app, and now once I put it on a blackberry bold, I've noticed that my text and images appear much smaller on the device than the simulator. Is there anyway to fix this without having to change every objects height and width? Maybe I need to use Display.getHeight() and .getWidth() more instead of hardcoding numbers?
One way I dealt with this is making the size of my elements variable. I did this by, upon loading the app, detecting the screen size and applying a multiplier that modifies my elements by a given %, the % depends on the screen size. I calculated these percentages by taking a base screen size and seeing how much the screen sized varied from one model to another, there are only 4 screen sizes I believe.
Yes, you shouldn't hardcode any number as bold and curve have differnt screen resolutions
Curve: 8800s, 8300s, 8500s, 9300s 320x240
Bold: 8900s, 9000s, 9600s, 9700s 480x360, 480x320 (Bold 9000)
You will have to change every place you used that numbers and change to gethHeight and getWidth() where needed
For the images you should scale the object, something like this:
Bitmap bitmap = new Bitmap(width, height);
yourBitmap.scaleInto(bitmap, Bitmap.FILTER_BILINEAR);
For texts you should use something like this:
LabelField field = new LabelField("TEST");
field.setFont(field.getFont().derive(Font.PLAIN, yourFontSize));

Blackberry Scrolling in Canvas

Hi friends I searched so many threads but I didnt get any solution for scrolling vertically
when the bitmaps are drawn using graphics with paint method.
Please help me.
If you are trying to (as Jonathan said) scroll trough an image that is larger than the screen.
To do it without any fancy function´s help and you are manually painting inside your graphics paint method, i would think of using 2 bitmaps, one as a buffer for your image and another one for the actual frame:
Have your large_image in a "buffer" bitmap, and then create another bitmap to use as a canvas and paint this canvas to the screen (the same size of the screen).
Clip your large_image to the size of the screen on the region of your bitmap that you want to paint on the next frame. Save that clipped bitmap to your canvas.
Draw that canvas bitmap.
Scroll the clipping of your large_image again (move x and y values) into your "canvas" bitmap
repeat 3 and 4 until scrolling ends.
Hope it is clear, think of it as having your canvas as a camera to take smaller snapshots of your large_image and moving the large_image so that each snapshot in sequence creates the scrolling effect.
Cheers and hope it helps!.

Resources