kliondictionary.blogg.se

Stretchblt copyimage
Stretchblt copyimage







HScale = pic2Width / pic1Width ' is a means of indentation Pic2Height = Me.ScaleY(pic2.Height, vbTwips, vbPixels) Pic2Width = Me.ScaleX(pic2.Width, vbTwips, vbPixels) Pic1Height = Me.ScaleY(pic1.Height, vbHimetric, vbPixels)

stretchblt copyimage

Pic1Width = Me.ScaleX(pic1.Width, vbHimetric, vbPixels) ImgLoader.Width = pic2.Width 'set target w/h 'imgLoader is a picturebox for temp storage of target picture If pic1 = 0 Then Exit Function 'no source picture 'check if the current StretchMode is set already 'isPictureBox specifies whether pic2 is a picturebox (true) or image (false)ĭoEvents 'make sure the source picture has loaded 'stretch mode specifies stretch mode: halftone, blackonwhite, whiteonblack, coloroncolor 'scale100 specifies whether scales >100% should be used (TRUE=yes) 'showRes specifies whether image resolution should be shown under the image 'positions image in the middle of pic2 automatically 'scales the image referenced as pic1 and stores it in pic2 Public Function scaleImage(pic1 As StdPicture, pic2 As Image) As Boolean Private Sub form_unload(cancel As Integer) 'in my real program I am of course loading different images, not the same one

stretchblt copyimage

'Set picLoader = LoadPicture("c:\img_1.jpg" ) 'this is a 1700x1200x24bit jpeg X = x + 1 'a simplistic arranging routine. Image1(i).Move x * Image1(0).Width / 2, y * Image1(0).Height / 2 ' /2 is to fit more images on the screen Set picLoader = LoadPicture("c:\img_1.jpg" ) 'this is a 1700x1200x24bit jpeg Me.WindowState = vbMaximized 'so that more images would fit in the window Private Declare Function CreateBitmap Lib "gdi32" (ByVal nWidth As Long, ByVal nHeight As Long, ByVal nPlanes As Long, ByVal nBitCount As Long, lpBits As Any) As Long Private Declare Function DeleteDC Lib "gdi32" (ByVal hdc As Long) As Long Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long

stretchblt copyimage

Private Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hdc As Long) As Long Private Declare Function GetStretchBltMode Lib "gdi32" (ByVal hdc As Long) As Long Private Declare Function SetStretchBltMode Lib "gdi32" (ByVal hdc As Long, ByVal nStretchMode As Long) As Long Private Declare Function StretchBlt Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal nSrcWidth As Long, ByVal nSrcHeight As Long, ByVal dwRop As Long) As Long Here is the simplified but fully working source code of this routine: After it's finished I'm copying the picturebox's picture to an Image Control.

stretchblt copyimage

I also have a picturebox whose DC i'm using as target picture.Īll of this i am passing to StretchBlt API. But win 98 compatibility is a requirement and i have to meet it.īasically, I am loading a large picture (1700x1200x24b) into a StdPicture, then creating a memory DC and getting the stdpicture's handle into this DC. Actually, it's not working as it should only under win 98, in win2k/xp everything works fine. Seems I can't make the StretchBlt API work as it should. I decided to post a 500 pts question because this has given me headache for about a week.









Stretchblt copyimage