Sign in to follow this  

gdi drawing a 1d texture to a window...

This topic is 3295 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello I have a float array defining a 1d texture (RGBA) I would like to display a bar with this texture in my gui. (i.e. i have a frame item in which i want (stretch) display that tex) I have the following code working for bitmaps loaded from resource, but I cant seem to link my float array correctly to display it. any suggestions would be appreciated very much if (msg == WM_PAINT) { // get frame window item HWND frame = GetDlgItem(hWnd,SPECTRUM); // get spectrum frame size RECT r; GetClientRect (GetDlgItem(hWnd,SPECTRUM),&r); int w = r.right; int h = r.bottom; here i determine the length of one 'spectrum' = float array (channels = 4bpp) grad1d should point to the 1d texture, taken from a a 2d, then the length is the length of the spectrum/bmp, and its only 1 pixel high int rowlen = mod.lights.nSpectrum * mod.lights.nChannels; float* grad1d = mod.lights.map + (l * rowlen ); int gradw = mod.lights.nSpectrum; int gradh = 1; // draw colormap PAINTSTRUCT ps; HDC hdc = BeginPaint(frame, &ps); SetStretchBltMode (hdc,HALFTONE); HDC hdcMem = CreateCompatibleDC(hdc); here im trying something, but get only as far as a black bar i guess im missing one or two lines here....... HBITMAP memBM = CreateCompatibleBitmap ( hdcMem, gradw, gradh ); SetBitmapBits (memBM, rowlen, grad1d); SelectObject (hdcMem, memBM ); StretchBlt (hdc, 0, 0, w, h, hdcMem, 0, 0, mod.lights.nSpectrum, mod.lights.nMaxLights, SRCCOPY); DeleteDC (hdcMem); EndPaint(GetDlgItem(hWnd,SPECTRUM), &ps); return 0; } thanx in advance

Share this post


Link to post
Share on other sites

This topic is 3295 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this