Discussions related to Visual Prolog
	
	
			
	
			
		
			
		
		
			
				
																			
								Steve Lympany  
						VIP Member 			
		Posts:  56Joined:  31 Mar 2001 23:01 
		
						
					
								
						
									Post by Steve Lympany  27 Jun 2011 9:33 
			
			
			
			
			Hi,
Is there a better way of doing the following, eg using iStream_native, rather than working on disk?
Code: Select all 
predicates 
    jpeg_picture: ( string JpegFile ) -> picture.
clauses 
    jpeg_picture( JPG ) = Picture :- 
                Workfile = "C:\\ a.bmp" , 
        Bitmap = bitmap:: createFromFile ( JPG ) , 
            gdiplus:: imageCodecInfo ( JpegId ,  _ ,  _ ,  _ ,  _ ,  _ ,  _ ,  _ ,  _ ,  _ ,  _ ,  _ ,  _ )  =  getEncoder( "BMP" ,  gdiplus:: imageEncoders ) , 
        Bitmap : saveToFile ( WorkFile ,  JpegId ,  uncheckedConvert( gdiplus:: encoderParameters ,  0 ) ) , 
        Picture = vpi:: pictLoad ( WorkFile ) .
cheers
steve
 
		 
				
		
		 
	 
				
		
		
			
				
								Tonton Luc  
						VIP Member 			
		Posts:  204Joined:  16 Oct 2001 23:01 
		
						
					
						                                                                                                                         
		 
								
						
									Post by Tonton Luc  27 Jun 2011 14:02 
			
			
			
			
			
			
			
									
									
						 
		 
				
		
		 
	 
				
		
		
			
				
																			
								Steve Lympany  
						VIP Member 			
		Posts:  56Joined:  31 Mar 2001 23:01 
		
						
					
						                                                                                                                         
		 
								
						
									Post by Steve Lympany  27 Jun 2011 18:42 
			
			
			
			
			Hi Tonton,
			
			
									
									
						 
		 
				
		
		 
	 
				
		
		
			
				
																			
								Paul Cerkez  
						VIP Member 			
		Posts:  108Joined:  6 Mar 2000 0:01 
		
						
					
						                                                                                                                         
		 
								
						
									Post by Paul Cerkez  29 Jun 2011 13:17 
			
			
			
			
			Steve,
			
			
									
									AI Rules!
						 
		 
				
		
		 
	 
				
		
		
			
				
								Tonton Luc  
						VIP Member 			
		Posts:  204Joined:  16 Oct 2001 23:01 
		
						
					
						                                                                                                                         
		 
								
						
									Post by Tonton Luc  29 Jun 2011 15:35 
			
			
			
			
			
Maybee you can used an invisible imageControl like :
Code: Select all 
        imageControl_ctl: setImageFile ( "your_picture.jpg" ) , 
        Img  =  imageControl_ctl: getImage ( ) , 
...and you recover a vpi::picture.
 
		 
				
		
		 
	 
				
		
		
			
				
																			
								Steve Lympany  
						VIP Member 			
		Posts:  56Joined:  31 Mar 2001 23:01 
		
						
					
						                                                                                                                         
		 
								
						
									Post by Steve Lympany  29 Jun 2011 18:05 
			
			
			
			
			Hi,
			
			
									
									
						 
		 
				
		
		 
	 
				
		
		
			
				
																			
								Steve Lympany  
						VIP Member 			
		Posts:  56Joined:  31 Mar 2001 23:01 
		
						
					
						                                                                                                                         
		 
								
						
									Post by Steve Lympany  11 Jul 2011 14:31 
			
			
			
			
			Hello again,
Still fiddling around with this. The following code is supposed to convert a jpg to a bitmap. The reason I do it this way is that if I do it without any sizing, a 6Mb JPG converts to a 200Mb BMP.  Unfortunately, the code below only produces a black bitmap.  
Any ideas?
Code: Select all 
predicates 
        jpgToBmp : ( string JpgFile ) .
clauses 
        jpgToBmp( JpgFile ) :- 
                Image = image:: createFromFile ( JpgFile ) , 
                Graphics = graphics:: createFromImage ( Image ) , 
                Bitmap = bitmap:: createFromGraphics ( 2000 , 2000 , Graphics ) ,  %resize 
                gdiplus:: imageCodecInfo ( BMPId ,  _ ,  _ ,  _ ,  _ ,  _ ,  _ ,  _ ,  _ ,  _ ,  _ ,  _ ,  _ )  =  getEncoder( "BMP" ,  gdiplus:: imageEncoders ) , 
                BitMapFile = fileName:: setExtension ( JpgFile , "bmp" ) , 
                Bitmap : saveToFile ( BitMapFile ,  BMPId ,  uncheckedConvert( gdiplus:: encoderParameters ,  0 ) ) , 
                stdio:: write ( "\n file " , BitMapFile , " saved \n " ) .
Thanks
regards
steve
You do not have the required permissions to view the files attached to this post.
			
									
						 
		 
				
		
		 
	 
				
		
		
			
				
																			
								Paul Cerkez  
						VIP Member 			
		Posts:  108Joined:  6 Mar 2000 0:01 
		
						
					
						                                                                                                                         
		 
								
						
									Post by Paul Cerkez  11 Jul 2011 22:48 
			
			
			
			
			Steve, 
			
			
									
									AI Rules!
						 
		 
				
		
		 
	 
				
		
		
			
				
																			
								Steve Lympany  
						VIP Member 			
		Posts:  56Joined:  31 Mar 2001 23:01 
		
						
					
						                                                                                                                         
		 
								
						
									Post by Steve Lympany  12 Jul 2011 7:25 
			
			
			
			
			Hi Paul,
I haven't tried. I want to open a jpg and use vpi::picture (which only reads a bmp). The following works:
Code: Select all 
predicates 
   jpgToBmp : ( string JpgFile ) .
clauses 
   jpgToBmp( JpgFile ) :- 
      Image = image:: createFromFile ( JpgFile ) , %or bitmap:: 
      gdiplus:: imageCodecInfo ( BMPId ,  _ ,  _ ,  _ ,  _ ,  _ ,  _ ,  _ ,  _ ,  _ ,  _ ,  _ ,  _ )  =  getEncoder( "BMP" ,  gdiplus:: imageEncoders ) , 
      Image : saveToFile ( BitMapFile ,  BMPId ,  uncheckedConvert( gdiplus:: encoderParameters ,  0 ) ) .
but this can create huge bmp files of course.
cheers
steve
 
		 
				
		
		 
	 
				
		
		
			
				
																			
								Paul Cerkez  
						VIP Member 			
		Posts:  108Joined:  6 Mar 2000 0:01 
		
						
					
						                                                                                                                         
		 
								
						
									Post by Paul Cerkez  12 Jul 2011 21:43 
			
			
			
			
			Steve,
			
			
									
									AI Rules!
						 
		 
				
		
		 
	 
				
		
		
			
				
																			
								Steve Lympany  
						VIP Member 			
		Posts:  56Joined:  31 Mar 2001 23:01 
		
						
					
						                                                                                                                         
		 
								
						
									Post by Steve Lympany  13 Jul 2011 8:49 
			
			
			
			
			Hi Paul,
			
			
									
									
						 
		 
				
		
		 
	 
				
		
		
			
				
								drspro2  
						VIP Member 			
		Posts:  111Joined:  28 Apr 2006 12:03 
		
						
					
								
						
									Post by drspro2  27 Jan 2016 15:49 
			
			
			
			
			In VIP 75 in the GDI plus example i can get the example working, (saving as bmp or jpg to file
			
			
									
									
						 
		 
				
		
		 
	 
				
		
		
			
				
								drspro2  
						VIP Member 			
		Posts:  111Joined:  28 Apr 2006 12:03 
		
						
					
						                                                                                                                         
		 
								
						
									Post by drspro2  27 Jan 2016 16:51 
			
			
			
			
			I think i might have found it,