Putting mask and image 
Author Message
 Putting mask and image

How can I PUT an image with a transparent color?
I dont want to do it all in a pixel loop because
thats too slow! I read about it and tried it like
this (it produces a wrong background):

  Create black and white mask of image, put it OR;
  Create negative image, put it XOR on mask!

Looks sth. like this (screen 13):

  DrawOriginalImage Position1
  DrawBlackAndWhiteImage Position2
  GET (Position2), mask
  GET (Position1), image
  PUT (Position1), image, PRESET
  GET (Position1), image

  CreateBackground

  PUT (Position3), mask, OR
  PUT (Position3), image, XOR

Thanks and bye, Jester

--
http://www.*-*-*.com/



Fri, 08 Oct 1999 03:00:00 GMT  
 Putting mask and image

Hello, Jester!

Quote:
> How can I PUT an image with a transparent color?
> I dont want to do it all in a pixel loop because
> thats too slow! I read about it and tried it like
> this (it produces a wrong background):

>   Create black and white mask of image, put it OR;
>   Create negative image, put it XOR on mask!

Try creating a black and white mask, put it AND;
then put the original (positive) image OR (see below).

Quote:

> Looks sth. like this (screen 13):

>   DrawOriginalImage Position1
>   DrawBlackAndWhiteImage Position2
>   GET (Position2), mask
>   GET (Position1), image
>   PUT (Position1), image, PRESET
>   GET (Position1), image

>   CreateBackground

>   PUT (Position3), mask, OR
>   PUT (Position3), image, XOR

> Thanks and bye, Jester

> --
> http://www.geocities.com/SiliconValley/Lakes/7784

Try this instead:

   DrawOriginalImage Position1
   GET (Position1), image
   DrawBlackAndWhiteImage Position1  <-- * Same position, see below
   GET (Position1), mask

   CreateBackground

------------------
|  GET (Position3), bgsave    <-- ** For animation, see below
|  PUT (Position3), mask, AND
L  PUT (Position3), image, OR
O
O  <Do other stuff, get key input, etc. while image on screen>
P
|  PUT (Position3), bgsave, PSET
|
|  <move position, scroll screen, etc. while image off screen>
------------------

* Your mask should should have the highest color in the palette for the screen
mode you're currently using (in the case of screen 13 that would be 255) in all
the pixels that your image is supposed to be transparent, and color 0 in all
the pixels in which the image has colors.  So, your mask should appear as a
"silhouette" of your image.  The best way I know to do this is to go over the
original image to create the mask.  Below is a SUB to do this, as it would be
used in the above code.

SUB DrawBlackAndWhiteImage (X%, Y%)

FOR X1 = X% TO X% + <width of the image>
  FOR Y1 = Y% TO Y% + <height of the image>
    IF POINT(X1, Y1) = 0 THEN PSET(X1, Y1), 255 ELSE PSET(X1, Y1), 0
  NEXT Y1
NEXT X1

END SUB

** If you plan on moving the image (i.e., animation), you should save the
background area where you will be PUTing your image into a temporary buffer
(DIMed to the same size as the image), so you can PUT it back later using PSET
when you need to "erase" the image from the background.

Hope this helps!

----
Thaumaturge
Stephen L. Maxson

"These new computers are so user-friendly,
we had to discontinue the lap-top model."



Sat, 09 Oct 1999 03:00:00 GMT  
 Putting mask and image

Hey I got it working now, thanks alot!

--
http://www.geocities.com/SiliconValley/Lakes/7784

Quote:

>(...)
> ------------------
> |  GET (Position3), bgsave    <-- ** For animation, see below
> |  PUT (Position3), mask, AND
> L  PUT (Position3), image, OR
> O
> O  <Do other stuff, get key input, etc. while image on screen>
> P
> |  PUT (Position3), bgsave, PSET
> |
> |  <move position, scroll screen, etc. while image off screen>
> ------------------

> * Your mask should should have the highest color in the palette for the screen
>(...)



Sat, 09 Oct 1999 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. How do I mask an image in VB4 to get rid of my image borders

2. How to put a image from a image box into an access file

3. Putting Image binary data into an image control

4. How to put a image from a image box into an access file

5. How to put edit mask in MaskEdBox?

6. Ol2000: Button Image, Face, Mask, pasteface

7. Icons - How to gain access to the Mask, image as well as the Color-table : ExtractIcon

8. Icons - How to gain access to the Mask, image as well as the Color-table : ExtractIcon

9. Cool button with masked image?

10. Masked image?

11. Image Control with Mask Color

12. Gray Mask Color in Image List

 

 
Powered by phpBB® Forum Software