Image in CPImageView does not show unless invoke setImageScaling:

28 views
Skip to first unread message

Joubert Nel

unread,
Dec 14, 2008, 5:41:10 PM12/14/08
to Cappuccino & Objective-J
From irc:

joubert: hi guys, I'm having an issue with CPImageView and CPImage
[5:18pm] joubert: I have a CPView subclass, to which I add a
CPImageView as a subview
[5:19pm] joubert: I instantiate a CPImage (using
initWithContentsOfFile:) and then do setImage: on the CPImageView
[5:19pm] joubert: but, the image never displays
[5:23pm] joubert: (btw, I can tell that the CPImageView is displaying,
because if I set its background color, it is surfaced.) So, wondering
why the setImage: doesn't appear to have the desired effect
[5:27pm] tolmasky_ left the chat room.
[5:30pm] joubert: hmmm
[5:30pm] joubert: seems like you have to do setImageScaling: before
the image will show up in the CPImageView
[5:30pm] joubert: by default the image doesn't display; not sure
whether that is the intention.

Joubert

Eisen Montalvo

unread,
Dec 14, 2008, 6:15:56 PM12/14/08
to objec...@googlegroups.com
Are you setting the size of the image?

Eisen

Sent from my iPhone 3G

Joubert Nel

unread,
Dec 14, 2008, 7:20:56 PM12/14/08
to Cappuccino & Objective-J
I didn't (well I guess when I called setImageScaling: I then set it
indirectly, which is why it worked).


On Dec 14, 6:15 pm, Eisen Montalvo <ei...@mac.com> wrote:
> Are you setting the size of the image?
>
> Eisen
>
> Sent from my iPhone 3G
>

Ross Boucher

unread,
Dec 14, 2008, 8:26:28 PM12/14/08
to objec...@googlegroups.com
There are flaws in the CPImage initWithContentsOfFile: method.

Basically, we need to know the size of the image, which is why there
is a version called initWithContentsOfFile:size:

You should use the second one whenever possible. Acknowledging that
sometimes you cannot know the size in advance, we have the first
method still, but we haven't been able to work out all the kinks yet.
That's why you need to set the image scaling mode.

You should file a ticket in lighthouse, though. This is something that
should get improved.

-Ross

Joubert Nel

unread,
Dec 16, 2008, 12:28:00 AM12/16/08
to Cappuccino & Objective-J


On Dec 14, 8:26 pm, Ross Boucher <rbouc...@gmail.com> wrote:

> You should file a ticket in lighthouse, though. This is something that  
> should get improved.

Done.

http://cappuccino.lighthouseapp.com/projects/16499-cappuccino/tickets/169-cpimage-initwithcontentsoffile-needs-scaling-set-before-image-is-visible

Reply all
Reply to author
Forward
0 new messages