I am trying to develop a small map-like application for BlackBerry. I have to know how I can put a small image on another big image.
The big image is like a map, I will need to point to a specific position to shorten that image. Therefore, the small image should be at the top of the large image at the same time, I will need to move the map, and the small image should follow that condition on the map.
Does anyone know that there is a specific API for this problem?
Icon icon on top of the map bitmap sample bitmap:
Square Scr increases the main screen {bitmap membmatmap = bitmap.jetbitmap resource ("map"); Bitmap mIconBitmap = bitmap.getbitmap resource ("icon.png"); Bitmap overwhelpbitmap (bitmap map, bitmap icon) {graphics g = new graphics (map); Int width = icon.getWidth (); Int height = icon.getHeight (); Int x = (map.getWidth () - width) / 2; Int y = (map.getHyight () - height) / 2; G.drawBitmap (x, y, width, height, icon, 0, 0); Return map; } Public Scr () {add (new Bitmapfield (getMonkeyBitmap, mIconBitmap)); Create the array of bitmap Create graphics with a new bitmap and draw all the bitmaps with defined alpha values Use custom class to save bitmap PNG image See example
Class Scr is expanded on main screen {bitmap [] images = new bitmap [0]; Int width = Display.getWidth (); Int height = Display.getHeight (); Bitmap bitmap = new bitmap (width, height); Bitmapfield bitmapfield = new bitmapfield (bitmap); Public Scr () {add (bitmapField); } Menu itemMedbitmap = new menu item ("add image", 0, 0) {public wide run (bit) {bitmap image = bitmap.jetbitmap resource ("img" + (image lamp + 1) + ".png"); Arrays.add (picture, image); Fresh (); }}; MenuItem mClean = New Menu ("Clean", 0, 0) {Public Zero Run () {images = new bitmap [0]; Fresh (); }}; MenuItem mSave = new menu item ("save", 0, 0) {public zero run () {string mFileName = System.getProperty ("fileconn.dir.photos") + "test.bmp"; // bitmap byte array conversion byte [] bitmap buffer = new byte [0]; PNGNcoder encoder = new PNG encoder (bitmap, true); Try {bitmapBuffer = encoder.encode (true); } Hold (IOException e) {e.printStackTrace (); } Write file (bitmap buffer, mFileName); }}; Private Zero write file (byte [] data, string filename) {FileConnection fconn = null; Try {fconn = (FileConnection) Connector.open (fileName, Connector.READ_WRITE); } Hold (IOException e) {System.out.print ("Error opening file"); } If (fconn.exists ()) try {fconn.delete (); } Hold (IOException e) {System.out.print ("error in file removal"); } Try {fconn.create (); } Hold (IOException e) {System.out.print ("Error creating file"); } OutputStream Out = Null; Try {out = fconn.openOutputStream (); } Hold (IOException e) {System.out.print ("Error opening the output stream"); } Try Out {Out.write (Data); } Hold (IOException e) {System.out.print ("Error writing in output stream"); } Try {fconn.close (); } Hold (IOException e) {System.out.print ("Error in closing file"); }} Zero Refresh () {bitmap = new bitmap (width, height); Graphics G = new graphics (bitmap); For (int i = 0; i
No comments:
Post a Comment