[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [pygame] Flood Filling Images
- To: pygame-users@xxxxxxxx
- Subject: Re: [pygame] Flood Filling Images
- From: "Brian Fisher" <brian@xxxxxxxxxxxxxxxxxxx>
- Date: Fri, 11 Apr 2008 19:57:16 -0700
- Delivered-to: archiver@xxxxxxxx
- Delivered-to: pygame-users-outgoing@xxxxxxxx
- Delivered-to: pygame-users@xxxxxxxx
- Delivery-date: Fri, 11 Apr 2008 22:57:20 -0400
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:sender:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; bh=7OsFjTsF8iYKYrmiXAelZxpEYa0MyZdDTph4tc21mBs=; b=m0tYS3F8EpdUknP+2pmU3nTNWabLBCCh8hVc3ZeCTpoEe5LtvydQ1uunErRiz5UqCODbWsXs1AN3iVO3vbQGbRD5rcbJ8WqhkpA5/7D+8b/HOYAnWysBZm0Dx1CBfvUV0A8CTECsFyA5a2+4s47R7Lz0GvyD0gEuEeAqi1ezhnc=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:sender:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; b=XTNbCO2VYnY2OcpHoft2TKa61WZ0YCFY26IA7In9yTzCpJs3rqQ5cpIbYJMCFl0oBw287la0PRRNtlvxEjtE1eoo+0SUvGpYAo+VYHT9w0VhesppQYD4MTXsc/B9Mg/IMsDTl3teul9It4O9ybZ1HIkY5Iyfh5J7vSkEtZws+kE=
- In-reply-to: <371c4f2f0804111853g4e937758g46223b52d90d95de@xxxxxxxxxxxxxx>
- References: <371c4f2f0804111853g4e937758g46223b52d90d95de@xxxxxxxxxxxxxx>
- Reply-to: pygame-users@xxxxxxxx
- Sender: owner-pygame-users@xxxxxxxx
What you describe isn't flood-filling - flood filling means painting
from a point (like the paint bucket) and it's for like filling circles
and stuff.
To answer your question though, pygame/sdl provides features identical
to PHP's imageColorSet and it's ilk. 8-bit images in pygame have
palettes (indexed colors). In particular, Surface.set_palette_at is a
direct imageColorSet equivalent.
If you don't want to use palette's, though, then checking each pixel
and replaceing each pixel (Color Replacement - what you have been
doing) is the only way to go, but Surface.get_buffer can be used to
make such things much faster.
On Fri, Apr 11, 2008 at 6:53 PM, Kevin <kevinmccloud@xxxxxxxxx> wrote:
> Hi, I'm looking for a fast way of "flood-filling" an image, like changing
> all green to red and such (akin to PHP's imageColorSet() function if that
> helps). The current method I'm looking at is locking the surface, getting
> every pixel on the surface one by one and then setting it if it's a certain
> color, and unlocking, but even the documentation says that's going to be
> slow (maybe it's fast enough with the new PyGame release?). There's a good
> chance I might have missed something in pygame.display, but any suggestions
> or pointing to some built-in thing would be appreciated.
>