How do I get natural dimensions of an image using JavaScript or jQuery?

You could use naturalWidth and naturalHeight, these properties contain the actual, non-modified width and height of the image, but you have to wait until the image has loaded to get them var img = document.getElementById(‘draggable’); img.onload = function() { var width = img.naturalWidth; var height = img.naturalHeight; } This is only supported from IE9 and … Read more

CUDA determining threads per block, blocks per grid

In general you want to size your blocks/grid to match your data and simultaneously maximize occupancy, that is, how many threads are active at one time. The major factors influencing occupancy are shared memory usage, register usage, and thread block size. A CUDA enabled GPU has its processing capability split up into SMs (streaming multiprocessors), … Read more

What is the difference between getWidth/Height() and getMeasuredWidth/Height() in Android SDK?

As the name suggests the measuredWidth/height is used during measuring and layoutting phase. Let me give an example, A widget is asked to measure itself, The widget says that it wants to be 200px by 200px. This is measuredWidth/height. During the layout phase, i.e. in onLayout method. The method can use the measuredWidth/height of its … Read more

If ScrollView only supports one direct child, how am I supposed to make a whole layout scrollable?

Just wrap your current LinearLayout with ScrollView. So it should be smth like this: <?xml version=”1.0″ encoding=”utf-8″?> <ScrollView xmlns:android=”http://schemas.android.com/apk/res/android” android:layout_width=”match_parent” android:layout_height=”match_parent”> <LinearLayout android:orientation=”vertical” android:layout_width=”match_parent” android:layout_height=”wrap_content”> <ImageButton … /> <TextView … /> <TextView … /> <TextView … /> </LinearLayout> </ScrollView>

How to get the Dimensions of a Drawable in an ImageView? [duplicate]

Just tried this out and it works for me: int finalHeight, finalWidth; final ImageView iv = (ImageView)findViewById(R.id.scaled_image); final TextView tv = (TextView)findViewById(R.id.size_label); ViewTreeObserver vto = iv.getViewTreeObserver(); vto.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { public boolean onPreDraw() { // Remove after the first run so it doesn’t fire forever iv.getViewTreeObserver().removeOnPreDrawListener(this); finalHeight = iv.getMeasuredHeight(); finalWidth = iv.getMeasuredWidth(); tv.setText(“Height: ” + finalHeight … Read more