Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file imagegdk.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475(***********************************************************************)(* *)(* Objective Caml *)(* *)(* Jun Furuse, projet Cristal, INRIA Rocquencourt *)(* *)(* Copyright 1999-2004, *)(* Institut National de Recherche en Informatique et en Automatique. *)(* Distributed only by permission. *)(* *)(***********************************************************************)(* $Id: imagegdk.ml,v 1.2 2009/03/01 09:49:53 furuse Exp $*)letinitialized=refNonelettry_initialize()=if!initialized=NonethenbeginGdk.Rgb.init();initialized:=Some(Gdk.Rgb.get_visual(),Gdk.Rgb.get_cmap())endopenOImagesletdraw(obj:#GDraw.drawable)?x?y?ditherimage=try_initialize();matchtagimage,image#blockswith|Rgb24image,(1,1)->letstring=fst(image#unsafe_access00)inletbuf=Gpointer.region_of_bytesstringinobj#put_rgb_data~width:image#width~height:image#height?x?y?dither~row_stride:(image#width*3)buf|_->failwith"Gdkrgb.draw"letto_pixbufimage=matchtagimage,image#blockswith|Rgb24image,(1,1)->letstring=fst(image#unsafe_access00)inletbuf=Gpointer.region_of_bytesstringin(* string may be GC'ed here? *)letpixbuf=GdkPixbuf.from_data~width:image#width~height:image#height~bits:8~rowstride:(image#width*3)~has_alpha:falsebufinpixbuf|Rgb24image,(w,h)->letdest=GdkPixbuf.create~width:image#width~height:image#height~bits:8~has_alpha:false()inforx=0tow-1dofory=0toh-1doletblk=image#dump_blockxyinletwidth=blk.Bitmap.Block.widthinletheight=blk.Bitmap.Block.heightinletbuf=Gpointer.region_of_bytesblk.Bitmap.Block.dumpinletpixbuf=GdkPixbuf.from_data~width~height~bits:8~rowstride:(width*3)~has_alpha:falsebufinGdkPixbuf.copy_area~dest~dest_x:blk.Bitmap.Block.x~dest_y:blk.Bitmap.Block.y~width~heightpixbufdonedone;dest|Cmyk32_,_->failwith"Gdkrgb.draw cmyk32"|_->failwith"Gdkrgb.draw"