How to copy a stretched image to clipboard?

How to copy a stretched image to clipboard?

Post by dos-man 6 » Sat, 02 May 2009 23:52:32

I've come up against this problem before in an old screen capture
program. Now I've made a little icon viewer and it's reared its ugly
head again.

The icon is first loaded into a picture control. This allows you to
view the actual size of the icon. Then the icon is copied into an
image control, which allows for a ZOOM feature by setting
IMAGE1.STRETCH = true.


There doesn't seem to be any way to copy the stretched image short of
alt+prntscr.

Image controls do not have an HDC, so I'm at a loss... Anyone have
any ideas on how this can be done?

dos-man

 
 
 

How to copy a stretched image to clipboard?

Post by Karl E. Pe » Sun, 03 May 2009 02:59:46


You could use PaintPicture to do the stretch, and copy the results.
--
.NET: It's About Trust!
http://www.yqcomputer.com/

 
 
 

How to copy a stretched image to clipboard?

Post by dos-man 6 » Sun, 03 May 2009 09:34:51


Are you sure it will work? The image control can copy its contents to
the clipboard, but I get an error about invalid image format.
Apparently, the clipboard object can only copy bitmaps and not
icons....
 
 
 

How to copy a stretched image to clipboard?

Post by Jeremiah D » Sun, 03 May 2009 10:36:02

On Fri, 1 May 2009 17:34:51 -0700 (PDT), dos-man 64



You can BitBlt a portion of the the desktop hDc to a DIB section. It
seems sloppy (imho, it is), but I've been forced to do it that way (by
a proprietary web camera interfce), and no worries so far after 5+
years.

J.
Jeremiah D. Seitz
Omega Techware
http://www.yqcomputer.com/
 
 
 

How to copy a stretched image to clipboard?

Post by Larry Serf » Sun, 03 May 2009 21:23:06


"dos-man 64" < XXXX@XXXXX.COM > wrote


The Image control does not stretch the picture. The original image is unchanged.
What you see is only a change in how the image is displayed.

To retain the icon's transparency, do it the other way around. Load the icon
into the Image control (Stretch set to False) and then paint in onto the
Picture control at its increased size. You can use PaintPicture to paint the
icon. What you can't do is add an icon to the Clipboard. As you saw, it
only accepts bitmap (or DIB) types. Depending on what you are doing,
you might be able to work it out using OLE Drag and Drop rather than
using the Clipboard (???)

For an example of using PaintPicture, add the code below to a form,
and run it. Then click on the form to see a large (Form default) icon.

LFS


Private Sub Form_Click()
' Paint the icon
PaintPicture Icon, 1000, 1000, 4000, 4000
End Sub

Private Sub Form_Load()
Const BKG = "BACKGROUND"
' Some Background artwork
AutoRedraw = True
DrawWidth = 15
Circle (3000, 3000), 2000, vbRed
Font.Size = 38
CurrentX = 3000 - (TextWidth(BKG) / 2)
CurrentY = 2700
Print BKG
End Sub
 
 
 

How to copy a stretched image to clipboard?

Post by dos-man 6 » Sun, 03 May 2009 22:17:07


> > IMAGE1.STRETCH rue. >> >>>> There doesn't seem to be any way to copy the stretched image short of >>>> alt+prntscr. >> >>>> Image controls do not have an HDC, so I'm at a loss... nyone have >>>> any ideas on how this can be done? >> >> The Image control does not stretch the picture. he original image is unchanged. >> What you see is only a change in how the image is displayed. >> >> To retain the icon's transparency, do it the other way around. oad the icon >> into the Image control (Stretch set to False) and then paint in onto the >> Picture control at its increased size. ou can use PaintPicture to paint the >> icon. hat you can't do is add an icon to the Clipboard. s you saw, it >> only accepts bitmap (or DIB) types. epending on what you are doing, >> you might be able to work it out using OLE Drag and Drop rather than >> using the Clipboard ???)> >> > For an example of using PaintPicture, add the code below to a form,> > and run it. hen click on the form to see a large (Form default) icon.> >> > LFS> >> > Private Sub Form_Click()> > ' Paint the ico>
> PaintPicture Icon, 1000, 1000, 4000, 40>0
> End S>b >>
> Private Sub Form_Load>)
> Const BKG = "BACKGROUN>"
> ' Some Background artw>rk
> AutoRedraw = >rue
> DrawWidth>= 15
> Circle (3000, 3000), 2000,>vbRed
> Font.Si>e = 38
> CurrentX = 3000 - (TextWidth(B>G) / 2)
> Curren>Y = 2700
> gt;Print BKG
> End Sub

Well, it works ok. I copied the stretched image to a hidden form, and
to the clipboard from there.
The image on the clipboard is a bit bigger than than the actual icon
for some reason, but it beats alt+prntscrn :D

Thank you
dos-man
 
 
 

How to copy a stretched image to clipboard?

Post by dos-man 6 » Mon, 04 May 2009 00:53:53


> > > IMAGE1.STRETCH rue. >> >>>>>> There doesn't seem to be any way to copy the stretched image short of >>>>>> alt+prntscr. >> >>>>>> Image controls do not have an HDC, so I'm at a loss... nyone have >>>>>> any ideas on how this can be done? >> >>>> The Image control does not stretch the picture. he original image is unchanged. >>>> What you see is only a change in how the image is displayed. >> >>>> To retain the icon's transparency, do it the other way around. oad the icon >>>> into the Image control (Stretch set to False) and then paint in onto the >>>> Picture control at its increased size. ou can use PaintPicture to paint the >>>> icon. hat you can't do is add an icon to the Clipboard. s you saw, it >>>> only accepts bitmap (or DIB) types. epending on what you are doing, >>>> you might be able to work it out using OLE Drag and Drop rather than >>>> using the Clipboard ???)> >> > > For an example of using PaintPicture, add the code below to a form,> > > and run it. hen click on the form to see a large (Form default) icon.> >> > > LFS> >> > > Private Sub Form_Click()> > > ' Paint the ico> >> > PaintPicture Icon, 1000, 1000, 4000, 40>0> > > End S>b >>> > > Private Sub Form_Load>)> > > Const BKG = "BACKGROUN>"> > > ' Some Background artw>r>
> > AutoRedraw = >r>e
> > DrawWidth>=>15
> > Circle (3000, 3000), 2000,>v>Red
> > Font.Si>e>= 38
> > CurrentX = 3000 - (TextWidth(B>G> / 2)
> > Curren>Y>= 2700
> > gt;P>int BKG
>>> >nd Sub
>
> Well, it works ok. copied the stretched image to a hidden>form, and
> to the clipboard f>om there.
> The image on the clipboard is a bit bigger than than the a>tual icon
> for some reason, but it beats alt+p>nt>crn :D
>
>>Thank you
> dos-man

Wait, I got rid of the hidden form and used a hidden picture box
instead. Now the clipboard image is the right size. Now I have to
tackle this transparency issue. I won't lose too much sleep if it
stays this way though.