Im in the process of creating an image component for use on an asp server. What I wanted to know if what is the best way to load two files and then merge them together, ie i load a canvas (what should i use for the canvas) and then load one file and "paste" it onto the canvas, then load a second file and "paste" that one onto it.
Thing is im not really sure on what to use for the canvas, ie picturebox or image, and about the pasting of the second images to it. (i assume you use bitblit or something like that)
Any way any help would be appreciated, i have searched around a bit for some other posts on similar stuff to this but couldnt really work out what the best way of doing this was.
Silverbug,
This space intentionally has nothing but text explaining why this
space has nothing but text explaining that this space would otherwise
have been left blank, and would otherwise have been left blank.
hmm, i dont really want to blend the two pictures, more paste one on the canvas and then paste the next picture somewhere else on the canvas (which could include over the top of the first picture)
Silverbug,
This space intentionally has nothing but text explaining why this
space has nothing but text explaining that this space would otherwise
have been left blank, and would otherwise have been left blank.
Using a Picturebox for the canvas and the BitBlt API should cover all of your bases. Look up the BitBlt API over at allapi.net. After you've gained a solid understanding, you'll need to realise a few things to get it to work.
1. If anything (source or destination) is going to be invisible during the BitBlt call, it must have it's AutoRedraw property set to true (Picturebox).
2. If AutoRedraw is set to true on the destination, issuing a .Refresh on the destination picturebox will make its contents visible once more.
If you can't seem to get your head around it, I can get myself out of Linux and write you up an example.
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
(Just a heads-up)
Ill take a crack at it and if I get stuck I'll let you know, thanks for the help.
Silverbug,
This space intentionally has nothing but text explaining why this
space has nothing but text explaining that this space would otherwise
have been left blank, and would otherwise have been left blank.
ok i know its probably something stupid but i keep getting a object variable or with block variable not set error whenever i try and use a picture box. i cant work out what ive done wrong
Dim Canvas As PictureBox
.....
Canvas.Width = strtemp
Canvas.Height = 9
The error occures on the line canvas.width....
Silverbug,
This space intentionally has nothing but text explaining why this
space has nothing but text explaining that this space would otherwise
have been left blank, and would otherwise have been left blank.
um no, bit of an undescriptive variable name but its an integer
basically when ever i try an access anything in any of my picture box variables they bring up the error.
to put things in perepective, im creating an asp component which will be used to create an image that is made up of x number of smaller image. its for a page counter.
Last edited by Silverbug; Dec 16th, 2002 at 12:49 AM.
Silverbug,
This space intentionally has nothing but text explaining why this
space has nothing but text explaining that this space would otherwise
have been left blank, and would otherwise have been left blank.
Yikes. This'll be a bit harder. I'm off to bed now, but tomorrow, I can show you how to "dive deep" into the GDI32 API... Wow I sound stupid, huh? Anyway, I'll show you about device contexts, how to make offscreen device contexts (a device context is simply a pointer to a graphical area), and how to merge images, etc. All using the API...
But it's late. If you want, you can look up all of those things yourself (bitblt, offscreen dcs, etc.) and try to make them fit... I dunno if I'm making any sense, I'm too tired!
So, g'night.
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
(Just a heads-up)
Yeah that would be cool. If anyone knows of any examples on this sorta stuff that would be cool. Kinda disapointed in whats happend to vbworld's site, was good unitll they merged
Silverbug,
This space intentionally has nothing but text explaining why this
space has nothing but text explaining that this space would otherwise
have been left blank, and would otherwise have been left blank.
Im still no closer to solving this damn problem, would be great if i could get some examples on how i can solve this (see 2-3 posts up) or if someone can explain how to join two pictures together and save the result, all in memory seeing as this is going to be an asp component.
Silverbug,
This space intentionally has nothing but text explaining why this
space has nothing but text explaining that this space would otherwise
have been left blank, and would otherwise have been left blank.
Okay. I wasn't able to respond before but I can now. Here's what I was going to tell you:
VB Code:
'// How to use BitBlt
Dim RC '// RC stands for Return Code.
'// Usually it doesn't matter (we can just throw it away), but it's useful if it doesn't work!
'// Prototype
'// RC = BitBlt([i]Destination[/i], [i]X Value (horizontal)[/i], [i]Y Value (vertical)[/i], [i]Width[/i], [i]Height[/i], [i]Source[/i], [i]X Value of Source (where to start getting data from horizontally), [i]Y Value of Source (where to start getting data from vertically)[/i], [i]How to Copy[/i])
'// Source and Destination are found by using the .hDC properties of pictureboxes, or just by offscreen device contexts (that's what DC stands for, the h stands for a handle, so it's a handle to a device context).
'// All Width, Y, X, etc. properties are in PIXELS. Remember to set your picturebox's ScaleMode property to 3 (pixels).
'// How to Copy: There are pre-defined constants starting with VB5 (I think) for the copy modes: SrcCopy (copy source bits to destination), SrcAnd (AND source bits with destination), SrcPaint, etc. SrcCopy is used for normal blits, SrcAnd/SrcPaint/MergePaint are used for transparent blitting (eg. mask is used to determine transparency).
'// This copies PicIn(0) onto PicOut at (0, 0) with a width and height of both 200 (you can also use PicIn(0).ScaleWidth, PicIn(0).ScaleHeight, etc.). It also uses the COPY constant to make the bits there equal the bits on the source (ex. no transformation).
'// You can also use AutoRedraw = True on all of the pictureboxes, and make them invisible.
'// You must use ***.Refresh to actually update the screen with the new picture. This allows games that use BitBlt (or other GDI calls) to wait until a monitor sync to draw, and also to make flicker-free drawing. If you didn't have autoredraw, you'd see the screen clearing and everything being drawn. With this you can make it show only when everything's already drawn.
Next post I'll show how to use OffScreen DCs! Make sure to use the API Viewer to get the BitBlt API Declaration, as well.
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
(Just a heads-up)
Hey great, thanks heaps for that... now how does it all tie together? (dont say string )
as in do i need to use DC's seeing as this is going to be an asp component?
Silverbug,
This space intentionally has nothing but text explaining why this
space has nothing but text explaining that this space would otherwise
have been left blank, and would otherwise have been left blank.
Here's what you might do. After you get the user's input (say, two files that are uploaded), run the component. It loads the two images in the same directory (image1.bmp and image2.bmp), and outputs image3.bmp. You create two DCs and load image1 and image2. Then you create a 3rd DC, use BitBlt to transfer both images on. Then, save this 3rd DC to a file (this is the only part I'm unsure of). You can be crafty and use this module called "freeimage" which can save to a variety of formats (png, jpg, gif, tiff, etc.)
I just forget where I got it from!
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
(Just a heads-up)
Ok im not quite sure on these dc thingys. (if you know of any good tuts on them its might save you explaining to me, ive had a search but cant find much on the topic)
One question tho, you say i should create three dc's (which i understand) and your example gets the dc of the desktop, does it have to be a dc of the desktop? and would that be the desktop of the client computer(browser) or of the server?
hmm in regards to saving i didnt really want to have to load more than one dll onto the server, (however if thats gona be a problem i guess thats all i can do) seeing as i dont own/admin the server, and am going to have to convince my hosting company to install it hehe
btw thanks for all your help on this.
Silverbug,
This space intentionally has nothing but text explaining why this
space has nothing but text explaining that this space would otherwise
have been left blank, and would otherwise have been left blank.
Well, once you run that DC function, you've got the DC (lngDC) that holds the image. If you aren't very graphics-minded, you can simply think of it as an image. Plain as that.
We load the desktop DC because it's guaranteed to be there. We need to set the DC's memory to be in the same format as the computer is currently using (pixel format [like bit depth], DPI, etc).
And finally, that would be of the server (because that's where the component runs). And, this can be only 1 DLL.
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
(Just a heads-up)
Hey I havent had much time to look at this (heaps of work atm ) but now that ive come back to it, i get errors. It cant find the GetDC function in the DC code.
Silverbug,
This space intentionally has nothing but text explaining why this
space has nothing but text explaining that this space would otherwise
have been left blank, and would otherwise have been left blank.
Last edited by Silverbug; Jan 12th, 2003 at 05:17 PM.
Silverbug,
This space intentionally has nothing but text explaining why this
space has nothing but text explaining that this space would otherwise
have been left blank, and would otherwise have been left blank.