Jump to content

Feature request: Pixel stretch


trickman

Recommended Posts

...(0 == src[x,y].A)...

Scaring me with that backwards stuff...:P

dst[x-1, y]

Never thought about that, but the destination has already been written....nice!

~~

Link to comment
Share on other sites

OK, what I want is to stretch something like this:

http://img143.imageshack.us/img143/1931/screen2it8.png

Is it possible to NOT stretch the alpha pixels and just the color pixels?

stretch which pixels in which direction?

isn't sepcot's last code snippet doing what you want?

how about giving some manually created before- and after-images, so people get what you are looking for :lol: :wink:

Link to comment
Share on other sites

OK, what I want is to stretch something like this:

http://img143.imageshack.us/img143/1931/screen2it8.png

Is it possible to NOT stretch the alpha pixels and just the color pixels?

stretch which pixels in which direction?

isn't sepcot's last code snippet doing what you want?

how about giving some manually created before- and after-images, so people get what you are looking for :lol: :wink:

What I simply want is for the code to take the last non-transparent pixel in each row and scretch it to the left or to the right!

sig6rj3.png
Link to comment
Share on other sites

OK, what I want is to stretch something like this:

http://img143.imageshack.us/img143/1931/screen2it8.png

Is it possible to NOT stretch the alpha pixels and just the color pixels?

stretch which pixels in which direction?

isn't sepcot's last code snippet doing what you want?

how about giving some manually created before- and after-images, so people get what you are looking for :lol: :wink:

What I simply want is for the code to take the last non-transparent pixel in each row and scretch it to the left or to the right!

well, sepcot's routine is doing that (apart of a few exceptions). in which way is it working wrong for you?
Link to comment
Share on other sites

What I simply want is for the code to take the last non-transparent pixel in each row and scretch it to the left or to the right!

Thank you for wording it that way!

Excuse me a minute...

~~

Link to comment
Share on other sites

Okay. Thank god. This is true:

void Render(Surface dst, Surface src, Rectangle rect)
{
   bool foundthis = false;
   for(int y = rect.Top; y < rect.Bottom; y++)
   {
       for (int x = rect.Left; x < rect.Right; x++)
       {
           if (src[x, y].A == 255 && foundthis == false) {
               foundthis = true;
               for (int x3 = x; x3 < rect.Right; x3++) {
                   ColorBgra col = src[x, y];
                   col.A = src[x3, y].A;
                   dst[x3,y] = col;
                   } 
               }
       }
       foundthis = false;
   }
}

Tell me if you don't like the white stripes you get from antialiasing...

EDIT: And rick, before you say anything...it works, and I believe it is thread safe, so hush.

~~

Link to comment
Share on other sites

Your welcome...That boolean statement is what did it :P

EDIT:Also, if you ever get black or white stripes in your image after applying this, here is a code to get rid of those:

void Render(Surface dst, Surface src, Rectangle rect)
{
   bool foundthis = false;
   for(int y = rect.Top; y < rect.Bottom; y++)
   {
       for (int x = rect.Left; x < rect.Right; x++)
       {
           if (src[x, y].A == 255 && foundthis == false) {
               foundthis = true;
               for (int x3 = x; x3 < rect.Right; x3++) {
                   ColorBgra col = src[x+1, y];
                   col.A = src[x3, y].A;
                   dst[x3,y] = col;
                   } 
               }
       }
       foundthis = false;
   }
}

~~

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...