From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: David Reitter Newsgroups: gmane.emacs.devel Subject: Re: png images in tool-bar / alpha mask Date: Sat, 5 Apr 2008 11:58:15 +0100 Message-ID: References: <6C1A0020-7B4B-4202-8757-B818A066D40A@gmail.com> <75A94D20-9656-4AD6-9A00-6C0EB26B2335@gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 (Apple Message framework v919.2) Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1207393125 15611 80.91.229.12 (5 Apr 2008 10:58:45 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 5 Apr 2008 10:58:45 +0000 (UTC) To: emacs- devel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Apr 05 12:59:16 2008 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1Ji676-00047z-KD for ged-emacs-devel@m.gmane.org; Sat, 05 Apr 2008 12:59:13 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ji66T-0005au-OP for ged-emacs-devel@m.gmane.org; Sat, 05 Apr 2008 06:58:33 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Ji66O-0005af-Ul for emacs-devel@gnu.org; Sat, 05 Apr 2008 06:58:29 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Ji66J-0005a8-IB for emacs-devel@gnu.org; Sat, 05 Apr 2008 06:58:27 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ji66J-0005a5-Dv for emacs-devel@gnu.org; Sat, 05 Apr 2008 06:58:23 -0400 Original-Received: from fk-out-0910.google.com ([209.85.128.190]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Ji66I-0000Bt-Q9 for emacs-devel@gnu.org; Sat, 05 Apr 2008 06:58:23 -0400 Original-Received: by fk-out-0910.google.com with SMTP id 26so653765fkx.10 for ; Sat, 05 Apr 2008 03:58:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:from:to:in-reply-to:content-type:content-transfer-encoding:mime-version:subject:date:references:x-mailer; bh=JiPvYQVPDi37ogyP5hXSein+kJhapu3+KmJIl+faMpM=; b=jzPUTunlcLDquFC76yuW09wGivSIZQDX7F1zqh2L81r42cWOr93XMrwkBrT6wCL3p39yRFGBvKoaTY2Zd/bZj4xqhXXEMSmpOl8Yc4BKWBeGXmC9FC2GEUbUFYNpS3i18DW1j05YtU9nndPvBghxBzT0bZhWkvStqxizTGIi9QM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:from:to:in-reply-to:content-type:content-transfer-encoding:mime-version:subject:date:references:x-mailer; b=wRvaeAUbgQ8aiT+5jhGsw/spf2dGX8zQTzHHlWFE76L8+X7al2rd9KR7B/IEtPb1auUXHFerT/mGYWmt1vvYxTuSr05Q36fdfITANZlfkVy6qwiJVrgzhsX32UmBB/onG26X6SS7IP1sPSb0uiTxJ/b+TjqVDbZRho7KeyGU10w= Original-Received: by 10.78.138.14 with SMTP id l14mr5221699hud.8.1207393098822; Sat, 05 Apr 2008 03:58:18 -0700 (PDT) Original-Received: from scarlett.lan ( [89.241.128.168]) by mx.google.com with ESMTPS id 35sm7126067nfu.36.2008.04.05.03.58.16 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 05 Apr 2008 03:58:17 -0700 (PDT) In-Reply-To: X-Mailer: Apple Mail (2.919.2) X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 2) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:94397 Archived-At: On 4 Apr 2008, at 13:20, YAMAMOTO Mitsuharu wrote: > > And the invalidation only takes care of the `mask' spec, but not for > `conversion'. Index: image.c =================================================================== RCS file: /sources/emacs/emacs/src/image.c,v retrieving revision 1.65.2.13 diff -c -r1.65.2.13 image.c *** image.c 28 Mar 2008 14:57:32 -0000 1.65.2.13 --- image.c 4 Apr 2008 15:05:11 -0000 *************** *** 1135,1140 **** --- 1135,1146 ---- struct image *img = IMAGE_FROM_ID (f, id); if (img->mask) mask = Qt; + #if USE_CG_DRAWING + /* Mask may be in an Alpha channel in the image data */ + if (img->data.ptr_val != NULL && + CGImageGetAlphaInfo(img->data.ptr_val) != kCGImageAlphaNone) + mask = Qt; + #endif } else error ("Invalid image specification"); *************** *** 1549,1555 **** } #if defined (MAC_OS) && USE_CG_DRAWING ! if (img->data.ptr_val) { CGImageRelease (img->data.ptr_val); img->data.ptr_val = NULL; --- 1555,1561 ---- } #if defined (MAC_OS) && USE_CG_DRAWING ! if (img->data.ptr_val != NULL) { CGImageRelease (img->data.ptr_val); img->data.ptr_val = NULL; *************** *** 1835,1840 **** --- 1841,1848 ---- { Lisp_Object conversion, spec; Lisp_Object mask; + int release = 0; + int found_p = 0; spec = img->spec; *************** *** 1850,1862 **** mask = image_spec_value (spec, QCheuristic_mask, NULL); if (!NILP (mask)) ! x_build_heuristic_mask (f, img, mask); else { - int found_p; - mask = image_spec_value (spec, QCmask, &found_p); ! if (EQ (mask, Qheuristic)) x_build_heuristic_mask (f, img, Qt); else if (CONSP (mask) --- 1858,1872 ---- mask = image_spec_value (spec, QCheuristic_mask, NULL); if (!NILP (mask)) ! { ! release = 1; ! x_build_heuristic_mask (f, img, mask); ! } else { mask = image_spec_value (spec, QCmask, &found_p); ! if (found_p) ! release = 1; if (EQ (mask, Qheuristic)) x_build_heuristic_mask (f, img, Qt); else if (CONSP (mask) *************** *** 1876,1882 **** /* Should we apply an image transformation algorithm? */ ! conversion = image_spec_value (spec, QCconversion, NULL); if (EQ (conversion, Qdisabled)) x_disable_image (f, img); else if (EQ (conversion, Qlaplace)) --- 1886,1895 ---- /* Should we apply an image transformation algorithm? */ ! found_p = 0; ! conversion = image_spec_value (spec, QCconversion, &found_p); ! if (found_p) ! release = 1; if (EQ (conversion, Qdisabled)) x_disable_image (f, img); else if (EQ (conversion, Qlaplace)) *************** *** 1893,1898 **** --- 1906,1918 ---- Fplist_get (tem, QCmatrix), Fplist_get (tem, QCcolor_adjustment)); } + #if defined (MAC_OS) && USE_CG_DRAWING + if (release && img->data.ptr_val != NULL) + { + CGImageRelease (img->data.ptr_val); + img->data.ptr_val = NULL; + } + #endif } } *************** *** 2767,2773 **** --- 2787,2798 ---- } CGContextDrawImage (context, rectangle, image); QDEndCGContext (ximg, &context); + + #if USE_CG_DRAWING + img->data.ptr_val = image; /* retain original data */ + #else CGImageRelease (image); + #endif /* Maybe fill in the background field while we have ximg handy. */ if (NILP (image_spec_value (img->spec, QCbackground, NULL)))