Android Question Using BitMapCreator to put a Border around a bmp

msains

Member
Licensed User
Longtime User
Calling BitMapCreator Experts.

I have a GrayScale Bitmap (see picture) of dimensions 199 x 262.
I would like to (programmatically) put a border around it and save it (again) as a .bmp

The border I put around it must cause the final combined bmp to ...
a) have dimensions of Exactly 512 x 512
b) The border must be filled with pixels that copy the original bmp's pixel(0, 0)

I guess another way of saying this is that I would like to place the original bmp more or less
in the centre of a new 512 x 512 bmp whose background is made up of pixels like the original's Pixel(0, 0)

For (arithmetical) simplicity let's say the borders dimensions would be (in pixels)
Top & Bottom Borders = 512 x 125,
Left Border = 157 x 512,
Right Border = 156 x 512

I'm really impressed by the BitMapCreator lib but just can't get into it that easily.
A bit of practical help (like the above) might help to get started into it more quickly.

Is this something that BitMapCreator can do (like - in its sleep) with only a few lines of code ?
 

Attachments

  • BabiesKitty_gs.jpg
    BabiesKitty_gs.jpg
    21.4 KB · Views: 238

Sagenut

Expert
Licensed User
Longtime User
I did not understood exactly what the Background should be.
This example does not use BitmapCreator but could give You and idea to make what You wish.
 

Attachments

  • Bitmap Border.zip
    30.9 KB · Views: 237
Upvote 0

emexes

Expert
Licensed User
The border I put around it must cause the final combined bmp to ...
a) have dimensions of Exactly 512 x 512
Depending on what you then do with the bordered image, another way might be:
- create a Panel that is 512 x 512 pixels
- add an ImageView to the panel, so that its position coordinates are relative to the panel
- load the .bmp to the ImageView
- set the Panel to be solid color of the (0, 0) pixel of the ImageView
- center horizontally with ImageView.Left = (Panel.Width - ImageView.Width) / 2
- center vertically likewise

You can then move the Panel around the screen as required.

Some panels have a SnapShot method that will return the image with the border.
 
Upvote 0

msains

Member
Licensed User
Longtime User
Thanking you guys profusely .... however I'm holding out for a BitMapCreator answer (if it is even appropriate of course) :)
 
Upvote 0

emexes

Expert
Licensed User
however I'm holding out for a BitMapCreator answer
No worries :) I know my post didn't meet your opening criteria, but I figured I'd pop out a different way of doing it anyway because:
1/ always good to have a backup plan
2/ usually good to see things from alternative perspective
 
Upvote 0

msains

Member
Licensed User
Longtime User
No worries :) I know my post didn't meet your opening criteria, but I figured I'd pop out a different way of doing it anyway because:
1/ always good to have a backup plan
2/ usually good to see things from alternative perspective
Thanks emexes, couldn't agree more ! A very nice solution that worked well. Awesome community of developers here - including yourself and SageNut.
 
Upvote 0

msains

Member
Licensed User
Longtime User
Here you are, with BitmapCreator:

View attachment 84773

Thank you Klaus. Very elegant and works great. I was experimenting in BMC with 'brushes' and not really getting anywhere. This is much simpler and I can work up to using 'brushes' later. I also appreciate all the comments in your code. You must be a teacher or lecturer because the explanations are brief but very instructive.
Thanks again.
 
Upvote 0
Top