I’m writing a program and import some bmp for texture mapping. Since my bmp is in 312288, but opengl texture map should be 2^n or 2^n + margin, so can I write apiece of code to convert my bmp to 512512 inside my program? if yes, which code is it?
If you are willing to use mipmapping, you can use gluBuild2DMipmaps : it will resize the image for you before actually building the mipmaps.
Else, you can write your own resizing code. Search for bicubic interpolation for best results.