I've looked all over the forum and cannot find an answer to this problem. I am writing a small app to place images as wallpaper on various phones and devices, nothing live and I am having a problem scaling the image when it is set as wallpaper.
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
This works fine on my phone (Samsung DUOS) (320x480) but in the emulator (400 x 800 mdpi) the image is not properly scaled (height and width) when it is set as wallpaper. However, the calculations above do return the size that I want the image to be.
Has someone had a similar experience and how did you solve it?
Thanks
			
			
			
				B4X:
			
		
		
		Sub SetWallPaper(Bmp As Bitmap)
  Dim r As Reflector
  Dim intHeight As Int
  Dim intWidth As Int
  Dim intOffset As Double
  Dim pScale As Double
  Dim aLayOut As LayoutValues
   
  aLayOut = GetDeviceLayoutValues
  pScale = GetDeviceLayoutValues.Scale
  ' calculate the height of the device in relation to the bitmap
  intOffset = (aLayOut.Height / Bmp.Height) * 0.8
  ' calculate the new height for the bitmap
  intHeight = Bmp.Height * intOffset * pScale
  ' calculate the new width for the bitmap
  intWidth = Bmp.Width * intOffset * pScale
  Bmp = f.CreateScaledBitmap(Bmp, intWidth, intHeight, True)
   
  r.Target = r.RunStaticMethod("android.app.WallpaperManager", "getInstance", Array As Object(r.GetContext), Array As String("android.content.Context"))
  r.RunMethod4("setBitmap", Array As Object(Bmp), Array As String("android.graphics.Bitmap"))
  Vibrate.Vibrate (50) ' Vibrate phone for 50 ms
  ToastMessageShow(wpWallpaperSet, False)
End SubThis works fine on my phone (Samsung DUOS) (320x480) but in the emulator (400 x 800 mdpi) the image is not properly scaled (height and width) when it is set as wallpaper. However, the calculations above do return the size that I want the image to be.
Has someone had a similar experience and how did you solve it?
Thanks
			
				Last edited: 
			
		
	
								
								
									
	
		
			
		
	
								
							
							 
				 
 
		 
 
		 
			 
			 
			 
 
		 
 
		 
 
		 
 
		