Change texture non-power of 2 setting at runtime?

We have an app that downloads images and creates textures from them using Texture2d.LoadImage() while you are using the app (runtime). These textures are used in the GUI.

Unfortunately, the textures created from these images look like crud, because Unity automatically scales them for power of 2 dimensions.

I know you can change a texture to a gui texture in the inspector, or you can use TextureImporter.npotScale = TextureImporterNPOTScale.None in an editor script, and the problem will be solved.

My question is, is there any way to accomplish this or any similar solution or workaround at runtime?

I forgot about this question. Anyway, I figured this out.

new Texture2D(...) 

does not, in fact, coerce a texture to be a square power of 2. The reason my textures looked like crud is that mip-mapping is turned on by default, and for whatever reason, unity sometimes uses smaller mip-maps for ui elements.

to turn off mip-mapping, use

new Texture2D(w, h, textureFormat, false)