I'm new to all this graphic stuff (never needed it til now) and I'm trying to rotate a bitmap without displaying it on a window...
The code below doesn't work because the bitblt is looking for a device context and I'm giving it a bitmap handle, but I'm not sure how to duplicate bitblt without a window. Any ideas???
Also, how do you save a handle of a memory bitmap to a disk file?
The code below doesn't work because the bitblt is looking for a device context and I'm giving it a bitmap handle, but I'm not sure how to duplicate bitblt without a window. Any ideas???
Also, how do you save a handle of a memory bitmap to a disk file?
Code:
function rotatedrawing(byval namefile$,byval ldegrees&) ff&=freefile open namefile$ for binary as #ff& base=0 seek #ff&,18 get$ #ff&,8,b$ close #ff& lwidth&=cvl(left$(b$,4)) lheight&=cvl(right$(b$,4)) graphic bitmap load namefile$,lwidth&,lheight& to hbmp& 'compute the radians from the input degrees lradians&=(3.14159)*ldegrees&/180 ' compute the sine/cosinse of the radians used to ' rotate this image lsine&=sin(lradians&) lcosine&=cos(lradians&) ' compute the size of the new bitmap being created x1&=-lheight&*lsine& y1&=lheight&*lcosine& x2&=lwidth&*lcosine&-lheight&*lsine& y2&=lheight&*lcosine&+lwidth&*lsine& x3&=lwidth&*lcosine& y3&=lwidth&*lsine& ' figure out the max/min size of the new bitmap lminx&=min(0,min(x1&,min(x2&,x3&))) lminy&=min(0,min(y1&,min(y2&,y3&))) lmaxx&=max(x1&,max(x2&,x3&)) lmaxy&=max(y1&,max(y2&,y3&)) ' set the new bitmap width/height lnewwidth&=lmaxx&-lminx& lnewheight&=lmaxy&-lminy& ''create a new bitmap based upon the new rotated bitmap hnewbmp&=createcompatiblebitmap(hbmp&,lnewwidth&,lnewheight&) ''translate each pixel to its new location using standard ''rotation algorithm for i&=0 to lnewheight& for j&=0 to lnewwidth& lsourcex&=(j&+lminx&)*lcosine&+(i&+lminy&)*lsine& lsourcey&=(i&+lminy&)*lcosine&-(j&+lminx&)*lsine& if (lsourcex&=>0) and (lsourcex&<=lwidth&) _ and (lsourcey&=>0) and (lsourcey&<=lheight&) then bitblt(hnewbmp&,j&,i&,1,1,hbmp&, _ lsourcex&,lsourcey&,%srccopy) end if next j& next i& ''lwidth&=lnewwidth& ''lheight&=lnewheight& deleteobject hbmp& ''how do I save hnewbmp& to namefile$ ??? deleteobject hnewbmp& function=1 end function
Comment