Posts

Showing posts with the label resize

Canvas drawImage scaling

Canvas drawImage scaling I'm trying to scale an image proportionately to the canvas. I'm able to scale it with fixed width and height as so: context.drawImage(imageObj, 0, 0, 100, 100) But I only want to resize the width and have the height resize proportionately. Something like the following: context.drawImage(imageObj, 0, 0, 100, auto) I've looked everywhere I can think of and haven't seen if this is possible. 3 Answers 3 context.drawImage(imageObj, 0, 0, 100, 100 * imageObj.height / imageObj.width) solution of @TechMaze is quite good. here is the code after some correctness and introduction of image.onload event. image.onload is too much essential in order to abstain from any kind of distortion. function draw_canvas_image() { var canvas = document.getElementById("image-holder-canvas"); var context = canvas.getContext("2d"); var imageObj = document.getElementB...

windowSoftInputMode=“adjustResize” not working with translucent action/navbar

windowSoftInputMode=“adjustResize” not working with translucent action/navbar I have problems with the translucent actionbar/navbar in the new Android KitKat (4.4) and the windowSoftInputMode="adjustResize" . windowSoftInputMode="adjustResize" Normaly changing the InputMode to adjustResize, the app should resize itself when keyboard is shown... but here it won't! If I delete the lines for the transparent effect, the resize is working. So if the keyboard is visible, my ListView is under it and I can't access the last few items. (Only by hiding the keyboard manually) AndroidManifest.xml <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="XYZ" android:versionCode="23" android:versionName="0.1" > <uses-sdk android:minSdkVersion="9" android:targetSdkVersion="19" /> <application android:al...