Results 1 to 16 of 16

Thread: certain color to background?

  1. #1

    Thread Starter
    Fanatic Member alkatran's Avatar
    Join Date
    Apr 2002
    Location
    Canada
    Posts
    860

    Question certain color to background?

    I was just wondering how you can make a bitmap image not cover the background. umm.. like.. if u had a picture of a circle, you wouldn't have the square of color around it, to make the game look better, and to LET ME USE A BACKGROUND (argh!!!)
    Don't pay attention to this signature, it's contradictory.

  2. #2
    Hyperactive Member Ambivalentiowa's Avatar
    Join Date
    Apr 2002
    Location
    Coming soon to a store near you!
    Posts
    375
    Use a gif instead of a bitmap. Not only will this allow you to have transparent backgrounds, it will also take up much less space file size.
    -Show me on the doll where the music touched you.

  3. #3

    Thread Starter
    Fanatic Member alkatran's Avatar
    Join Date
    Apr 2002
    Location
    Canada
    Posts
    860

    Question movie file?

    a .gif is a movie-like file isn't it?? (and uh, what do I use to make em). I've also seen programs that used bitmaps where a certain color didn't go, to allow to see background.
    Don't pay attention to this signature, it's contradictory.

  4. #4
    Hyperactive Member Ambivalentiowa's Avatar
    Join Date
    Apr 2002
    Location
    Coming soon to a store near you!
    Posts
    375
    1: A .gif is not a movie file. It's another type of picture

    2: Use Ms Paint or any imaging program to make them
    -Show me on the doll where the music touched you.

  5. #5
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Oregon
    Posts
    962
    To create "transperant" bitmaps, read the next two paragraphs.

    If your using directx, use an alpha mask. If your using bitblt, use a mask.

    For bitblt, the mask would be gray-scale (most commonly b&w). The darker it is, the less visiable the background. Use srcAnd to paint the mask, and srcPaint to paint the main image (sprit).

    If you are using image boxs, use gifs. If you happen to have photoshop, it can create gifs. Gifs can be animated, but it is not required.


    Hope this helps.
    Involved in: Sentience

  6. #6

    Thread Starter
    Fanatic Member alkatran's Avatar
    Join Date
    Apr 2002
    Location
    Canada
    Posts
    860

    mask?

    ok... so I paint back of the bitmap with srcand and the front with srccopy, but... how does vb know what's back and what's front?
    Don't pay attention to this signature, it's contradictory.

  7. #7
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Oregon
    Posts
    962
    You need two differnt images (or differnt parts of the image). With bitblt (it may work with paintpicture too), you speicify the locations, and area to copy. One of the images is the actual image to display (with a white background), and the other is the mask (lighter = more transpartent). You then use srcAnd on the mask, and srcCopy on the image.
    Involved in: Sentience

  8. #8
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    Mmm, no. You use vbSrcAnd on the mask source, and vbSrcPaint on the sprite source. If you have a non-black background this will not work unless you blit the mask on with vbMergePaint and the Sprite with vbSrcAnd. However the partial transparency will not work with this second method.

    If you ever need a resource, I had a "BitBlt Case Studies" a while ago, that nobody ever used. Maybe I could get it stickied
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  9. #9
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Oregon
    Posts
    962
    Oops, I wrote it wrong the second time
    Involved in: Sentience

  10. #10
    Junior Member French_gal's Avatar
    Join Date
    Apr 2002
    Posts
    31
    If you have Adobe it is a great program for converting any tipe of picture to gif. and making it transparent..
    e=2.718281828459045235360287471352662497757247093699959574

  11. #11

    Thread Starter
    Fanatic Member alkatran's Avatar
    Join Date
    Apr 2002
    Location
    Canada
    Posts
    860

    hurrah! (white flicker?)

    I used paint.picture to do it
    I never realied u guys meant make a white area over where the image would be and black for the back (i did all white/black for awhile ) but I got it, only prob is there's a white flicker when I place the image because of the mask, any ideas?
    Don't pay attention to this signature, it's contradictory.

  12. #12
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Oregon
    Posts
    962
    One of two ways that I have heard work:
    1) paint them on to a back buffer, then copy them to the visable image. Make sure that the back buffer has autoredraw on.
    2) turn on auto redraw, then use picture1.refresh to make the image visable.

    Make sure to only do the copy/refresh after the whole frame has been drawn.
    Involved in: Sentience

  13. #13

    Thread Starter
    Fanatic Member alkatran's Avatar
    Join Date
    Apr 2002
    Location
    Canada
    Posts
    860

    back buffer?

    back buffer? and wont that kinda cause the background to go solid again? Making it a big pointless circle.... hmm...
    Don't pay attention to this signature, it's contradictory.

  14. #14
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Oregon
    Posts
    962
    You paint the whole frame to the back buffer, then copy it to the front buffer. The other way is to turn autoredraw on the front/only buffer, then refresh that picture box. In this way, the new frame woun't be visable until it is intirely drawn.
    Involved in: Sentience

  15. #15

    Thread Starter
    Fanatic Member alkatran's Avatar
    Join Date
    Apr 2002
    Location
    Canada
    Posts
    860

    Allow me to repeat...

    back buffer? what's the back buffer?
    Don't pay attention to this signature, it's contradictory.

  16. #16
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Oregon
    Posts
    962
    Two ways, both with code below:

    1) To use that way, you need 2 picture boxes. One is the front buffer (no autoredraw), and the other is the back buffer (with autoredraw). You draw everything to the back buffer (in order: background [srccopy], mask [srcand], then sprite [srcpaint]), then copy the backbuffer to the frontbuffer [srccopy].

    2) You can also turn autoredraw on the frontbuffer (you woun't need a backbuffer this way), then refresh the picture box after you finish drawing the frame (in order: background [srccopy], mask [srcand], then sprite [srcpaint]).


    The following code assumes that the backbuffer is named backbuffer, the mask is named mask, the sprite is named image, and the frontbuffer is named frontbuffer. it also asumes that all the images are in differnt picture boxes. All the images need to be in picture boxes, you may combine the image and mask, changing the source xs, ys, and hdcs. The declation can be found in the API viewer (as it is not installed on the computer I am currently using).

    1) This code requires a back buffer.
    VB Code:
    1. bitblt backbuffer.hdc, 0,0,backbuffer.scalewidth, backbuffer.scaleheight, background.hdc,0,0, srccopy
    2. bitblt backbuffer.hdc, X,Y,mask.scalewidth, mask.scaleheight, mask.hdc,0,0, srcand
    3. bitblt backbuffer.hdc, 0,0,image.scalewidth, image.scaleheight, image.hdc,0,0, srcpaint
    4. bitblt frontbuffer.hdc, 0,0,backbuffer.scalewidth, backbuffer.scaleheight, backbuffer.hdc,0,0, srccopy

    2) This code doesn't need a backbuffer.
    VB Code:
    1. bitblt frontbuffer.hdc, 0,0,frontbuffer.scalewidth, frontbuffer.scaleheight, background.hdc, srccopy
    2. bitblt frontbuffer.hdc, X,Y,mask.scalewidth, mask.scaleheight, mask.hdc, srcand
    3. bitblt frontbuffer.hdc, 0,0,image.scalewidth, image.scaleheight, image.hdc, srcpaint
    4. frontbuffer.refresh
    Involved in: Sentience

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width