[LON-CAPA-cvs] cvs: loncom /homework randomlylabel.pm

albertel lon-capa-cvs@mail.lon-capa.org
Tue, 13 May 2003 19:08:31 -0000


albertel		Tue May 13 15:08:31 2003 EDT

  Modified files:              
    /loncom/homework	randomlylabel.pm 
  Log:
  - subimages get placed properly
  - missing subimages don't cause things to blow up and log an error
  
  
Index: loncom/homework/randomlylabel.pm
diff -u loncom/homework/randomlylabel.pm:1.8 loncom/homework/randomlylabel.pm:1.9
--- loncom/homework/randomlylabel.pm:1.8	Thu Feb 27 16:36:27 2003
+++ loncom/homework/randomlylabel.pm	Tue May 13 15:08:31 2003
@@ -2,7 +2,7 @@
 # The LearningOnline Network with CAPA
 # randomlabel.png: composite together text and images into 1 image
 #
-# $Id: randomlylabel.pm,v 1.8 2003/02/27 21:36:27 albertel Exp $
+# $Id: randomlylabel.pm,v 1.9 2003/05/13 19:08:31 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -50,7 +50,7 @@
 	GD::Image->trueColor(1);
 	$image = GD::Image->new($imgsrc);
     }
-    if ($set_trans) {
+    if ($set_trans && defined($image)) {
 	my $white=$image->colorExact(255,255,255);
 	if ($white != -1) { $image->transparent($white); }
     }
@@ -76,7 +76,12 @@
     }
     for(my $i=0;$i<$ENV{"form.ICOUNT"};$i++) {
 	my $subimage=&get_image($ENV{"form.IMG$i"},1);
-	$image->copy($subimage,$ENV{"form.X$i"},$ENV{"form.Y$i"},
+	if (!defined($subimage)) {
+            &Apache::lonnet::logthis('Unable to create image object for '.
+                                 $ENV{"form.BGIMG"});
+            next;
+        }
+	$image->copy($subimage,$ENV{"form.IX$i"},$ENV{"form.IY$i"},
 		     0,0,$subimage->getBounds());
     }
     my $height=GD::Font->Giant->height;