ok i've got a Bmp that i've loaded in mem
how can i display it in a Popup Window
and then by clicking on a button
Plot a point on this pic (Different color than the One was)
it will be used in a loop to show user which pixel is 'Scanned'
How can i Do It
help me please
Posted on 2002-11-30 06:12:32 by Thor0Asgard
when initializing the WNDCLASSEX-structure, assign the hbrBackground-value the handle of your bitmap:



LOCAL wc:WNDCLASSEX
...
invoke LoadBitmap,hInstance,BG ;BG is the ResourceID of your bitmap
mov hBG,eax
mov wc.hbrBackground,eax
...


for your pixel-plotting problem is a api availible:


COLORREF SetPixel(

HDC hdc, // handle of device context
int X, // x-coordinate of pixel
int Y, // y-coordinate of pixel
COLORREF crColor // pixel color
);


use it like this


LOCAL dc:HDC
LOCAL COLOR:DWORD
...
mov COLOR,00BBGGRR ;yes, it's BGR in this case, not RGB!
invoke GetWindowDC,hWin
mov dc,eax
invoke SetPixel,dc,X,Y,COLOR
invoke ReleaseDC,hWin,dc
...


btw, i wonder, why i've written a sample code...
Posted on 2002-11-30 08:55:08 by hartyl
1st: thanks for the code
2nd:how do i resize my pop-up window to the size of my pic ex:640x480
but pics can be different size
so how to translate Pic Resolution to WinSize
There will be Only My Pic In This WinDow
Posted on 2002-11-30 13:48:31 by Thor0Asgard
Use the api MoveWindow.

It will help you to resize your window and move it
Posted on 2002-12-01 01:11:03 by roticv
i've just used setpixel in a routine and was surprised at just how slow it is,

i imagine you are trying to show the progress of an operation on an image?

maybe better to directly manipulate the bitmap data in memory then blt the updated region to the screen
Posted on 2002-12-01 06:52:05 by Terab
Ok it will bill maybe faster to maniplate the bitmap into mem
but is a blitbit for only 1 pix (maybe i've to set it to the 4 environant pix to make it Quarter for the region set) will be faster
and even if it is too slow my only wish is to shiow user a progress on bitmap analisys
Pixel Per Pxiel so....

can someone give me some code to do it by blt
thx
Posted on 2002-12-01 07:31:05 by Thor0Asgard
in your case setpixel will propably be faster

although maybe thread the image processing and then have an update routine that blt's the updates every 100 ms or so, would be more responsive.




invoke SelectObject,dcMem,hYourBitmap
mov BMemOld,eax

;now bitblt into the new dc
invoke BitBlt,dcMem,0,0,Xsize,Ysize,TDC,TopX,TopY,SRCCOPY



invoke SetPixel,dcMem,xpw,ypw,RequiredRGB ;xpw,ypw being the pixel position


and last but not least blt to the main screen - i like to back buffer gets rid of flicker

dont forget to unselect our object as can only be selected into 1 dc at a time
Posted on 2002-12-02 01:39:57 by Terab
how to size my window to my pic resolution

i'll create a popup window with only a bitmap displayed no menu maybe a titlebar
but that's all
so i have the pic res for exampe 640x480
how can i translate it to window size
thanks
Posted on 2002-12-02 08:32:12 by Thor0Asgard
GetObject... Fills up the BITMAP structure with the height and width of the Bitmap which is in window pixels :)


Add Size of TitleBar to Height and call MoveWindow. Something like that to prevent the Bitmap to be cut off at the bottom.

(be happy you don't have the mesures in log inches :tongue: )


Posted on 2002-12-02 08:44:12 by JimmyClif
thanks but how can i get the size of my title bar ?
sorry for asking but please helpme
Posted on 2002-12-02 09:45:36 by Thor0Asgard
you can get the current size of the systems
caption using GetSystemMetrics and
using the SM_CYCAPTION, this will return
the height of a windows caption area.

invoke GetSystemMetrics,SM_CYCAPTION

If you want code to read a BMP file into
memory and get it's size ect then display
it, just tell me and I will make one quick
for you, I can even show you how to get
a pixel color at any point in the bitmap
and even change that pixel color.



Zcoder.....
Posted on 2002-12-02 11:38:24 by Zcoder
it work perfectly so thanks all for that
and yes zcoder post some code
Posted on 2002-12-02 12:11:22 by Thor0Asgard
Ok, give me about a day or so and I will
post some code. I promise this code will
be worth the wait.

remember this is what I am on this
forum for, anyone willing to wait a
day or two will get the code they
are looking for.


Zcoder....
Posted on 2002-12-02 19:53:33 by Zcoder
i'll wait thanks
Posted on 2002-12-02 20:06:32 by Thor0Asgard
instead of:

invoke GetSystemMetrics,SM_CYCAPTION

you can use something more complex:

local rect1:RECT
local rect2:RECT

invoke GetWindowRect,hWnd,addr rect1
invoke GetClientRect,hWnd,addr rect2
mov eax,rect1.right
mov ecx,rect1.bottom
sub eax,rect1.left
sub ecx,rect1.top
;now in eax and ecx you got window coordinates

sub eax,rect2.right
sub ecx,rect2.bottom
;now in eax,ecx you have sizes of caption+borders+menu+stuff

add eax,640
add ecx,480
;here you add the new client sizes you want

invoke MoveWindow,hWnd,rect1.left,rect1.top,eax,ecx,TRUE
Posted on 2002-12-03 04:16:53 by stolarz
Here is the example on how to
load a bitmap file from disk and
get the size of the bitmap from
the bitmap info and resize the window
to the bitmap.

It also displays in the window the bitmap
color table used in the bitmap.

I have included some bitmaps in the example.
don't use 24 bit or higher bitmaps, as I did not
write the example program to handle all types
mostly 1,4,8,16 bit bitmaps.

If there is more you would like me to add
to this example so show how to set colors
in the bitmap I can write the code for that as
well.

I just want to make sure I don't write a complete
paint program. LOL but I could, as I find it fun.
remember this example does NO error checking
NONE, it is just to show you what steps are needed
to get the job done.

Zcoder....
Posted on 2002-12-03 16:17:33 by Zcoder