carlosnz-image_science 1.1.3 → 1.1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/image_science.rb +39 -0
- metadata +1 -1
data/lib/image_science.rb
CHANGED
@@ -79,6 +79,13 @@ class ImageScience
|
|
79
79
|
def composite;
|
80
80
|
end
|
81
81
|
|
82
|
+
#
|
83
|
+
# overlays a foreground image onto this image, tries to ensure the correct bit depths
|
84
|
+
# note: make sure images are the same size
|
85
|
+
#
|
86
|
+
def with_overlay; #:yields: image
|
87
|
+
end
|
88
|
+
|
82
89
|
##
|
83
90
|
# Creates a proportional thumbnail of the image scaled so its longest
|
84
91
|
# edge is resized to +size+ and yields the new image.
|
@@ -291,6 +298,38 @@ class ImageScience
|
|
291
298
|
}
|
292
299
|
END
|
293
300
|
|
301
|
+
builder.c <<-"END"
|
302
|
+
VALUE with_overlay(VALUE foreground_image) {
|
303
|
+
VALUE result = Qnil;
|
304
|
+
FIBITMAP *foregroundImage = NULL;
|
305
|
+
FIBITMAP *compositeImage = NULL;
|
306
|
+
FIBITMAP *foreground32Image = NULL;
|
307
|
+
FIBITMAP *background24Image = NULL;
|
308
|
+
GET_BITMAP(bitmap);
|
309
|
+
|
310
|
+
Data_Get_Struct(foreground_image, FIBITMAP, foregroundImage);
|
311
|
+
|
312
|
+
if (foreground32Image = FreeImage_ConvertTo32Bits(foregroundImage)) {
|
313
|
+
copy_icc_profile(self, foregroundImage, foreground32Image);
|
314
|
+
|
315
|
+
if (background24Image = FreeImage_ConvertTo24Bits(bitmap)) {
|
316
|
+
copy_icc_profile(self, bitmap, background24Image);
|
317
|
+
|
318
|
+
if (compositeImage = FreeImage_Composite(foreground32Image, FALSE, NULL, background24Image)) {
|
319
|
+
copy_icc_profile(self, foreground32Image, compositeImage);
|
320
|
+
result = wrap_and_yield(compositeImage, self, 0);
|
321
|
+
}
|
322
|
+
|
323
|
+
FreeImage_Unload(background24Image);
|
324
|
+
}
|
325
|
+
|
326
|
+
FreeImage_Unload(foreground32Image);
|
327
|
+
}
|
328
|
+
|
329
|
+
return result;
|
330
|
+
}
|
331
|
+
END
|
332
|
+
|
294
333
|
builder.c <<-"END"
|
295
334
|
int height() {
|
296
335
|
GET_BITMAP(bitmap);
|